com/hypixel/hytale/server/core/auth/AuthConfig.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.common.util.java.ManifestUtil;
import javax.annotation.Nonnull;
public class AuthConfig {
public static final String USER_AGENT = "HytaleServer/" + ManifestUtil.getImplementationVersion();
public static final String OAUTH_AUTH_URL = "https://oauth.accounts.hytale.com/oauth2/auth" ;
public static final String OAUTH_TOKEN_URL = "https://oauth.accounts.hytale.com/oauth2/token" ;
public static final String DEVICE_AUTH_URL = "https://oauth.accounts.hytale.com/oauth2/device/auth" ;
public static final String CONSENT_REDIRECT_URL = "https://accounts.hytale.com/consent/client" ;
public static final String SESSION_SERVICE_URL = "https://sessions.hytale.com" ;
public static final String ACCOUNT_DATA_URL = "https://account-data.hytale.com" ;
public static final String BUILD_ENVIRONMENT = "release" ;
public static final String CLIENT_ID = "hytale-server" ;
public static final String[] SCOPES = new String []{"openid" , "offline" , "auth:server" };
public static final String SCOPE_CLIENT = "hytale:client" ;
public static final String SCOPE_SERVER = "hytale:server" ;
public static final String SCOPE_EDITOR = "hytale:editor" ;
public static final int HTTP_TIMEOUT_SECONDS = 10 ;
public static final int DEVICE_POLL_INTERVAL_SECONDS = 15 ;
public static final String ENV_SERVER_AUDIENCE = "HYTALE_SERVER_AUDIENCE" ;
public static final String ENV_SERVER_IDENTITY_TOKEN = "HYTALE_SERVER_IDENTITY_TOKEN" ;
public static final String ENV_SERVER_SESSION_TOKEN = "HYTALE_SERVER_SESSION_TOKEN" ;
private static final String SERVER_AUDIENCE_OVERRIDE = System.getenv("HYTALE_SERVER_AUDIENCE" );
@Nonnull
public static String getServerAudience () {
return SERVER_AUDIENCE_OVERRIDE != null ? SERVER_AUDIENCE_OVERRIDE : ServerAuthManager.getInstance().getServerSessionId().toString();
}
private AuthConfig () {
}
}
com/hypixel/hytale/server/core/auth/AuthConfigGenerated.java
package com.hypixel.hytale.server.core.auth;
final class AuthConfigGenerated {
static final String DOMAIN = "hytale.com" ;
static final String ENVIRONMENT = "release" ;
private AuthConfigGenerated () {
}
}
com/hypixel/hytale/server/core/auth/AuthCredentialStoreProvider.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
import javax.annotation.Nonnull;
public interface AuthCredentialStoreProvider {
BuilderCodecMapCodec<AuthCredentialStoreProvider> CODEC = new BuilderCodecMapCodec <AuthCredentialStoreProvider>("Type" , true );
@Nonnull
IAuthCredentialStore createStore () ;
}
com/hypixel/hytale/server/core/auth/CertificateUtil.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.logger.HytaleLogger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.Base64;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class CertificateUtil {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
public CertificateUtil () {
}
@Nullable
public static String computeCertificateFingerprint (@Nonnull X509Certificate certificate) {
try {
MessageDigest sha256 = MessageDigest.getInstance("SHA-256" );
byte [] certBytes = certificate.getEncoded();
byte [] hash = sha256.digest(certBytes);
return base64UrlEncode(hash);
} catch (NoSuchAlgorithmException e) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(e)).log("SHA-256 algorithm not available" );
return ;
} (CertificateEncodingException e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
{
(jwtFingerprint != && !jwtFingerprint.isEmpty()) {
(clientCert == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
computeCertificateFingerprint(clientCert);
(actualFingerprint == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
timingSafeEquals(jwtFingerprint, actualFingerprint);
(!matches) {
LOGGER.at(Level.WARNING).log( , jwtFingerprint, actualFingerprint);
} {
LOGGER.at(Level.INFO).log( );
}
matches;
}
}
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
{
(a != && b != ) {
[] aBytes = a.getBytes(StandardCharsets.UTF_8);
[] bBytes = b.getBytes(StandardCharsets.UTF_8);
MessageDigest.isEqual(aBytes, bBytes);
} {
a == b;
}
}
String {
Base64.getEncoder().encodeToString(input);
base64.replace( , ).replace( , ).replace( , );
}
}
com/hypixel/hytale/server/core/auth/DefaultAuthCredentialStore.java
package com.hypixel.hytale.server.core.auth;
import java.time.Instant;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class DefaultAuthCredentialStore implements IAuthCredentialStore {
private IAuthCredentialStore.OAuthTokens tokens = new IAuthCredentialStore .OAuthTokens((String)null , (String)null , (Instant)null );
@Nullable
private UUID profile;
public DefaultAuthCredentialStore () {
}
public void setTokens (@Nonnull IAuthCredentialStore.OAuthTokens tokens) {
this .tokens = tokens;
}
@Nonnull
public IAuthCredentialStore.OAuthTokens getTokens () {
return this .tokens;
}
public void setProfile (@Nullable UUID uuid) {
this .profile = uuid;
}
@Nullable
public UUID getProfile () {
.profile;
}
{
.tokens = .OAuthTokens((String) , (String) , (Instant) );
.profile = ;
}
}
com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStore.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.util.HardwareUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.util.BsonUtil;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.security.SecureRandom;
import java.time.Instant;
import java.util.UUID;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import org.bson.BsonDocument;
public class EncryptedAuthCredentialStore implements IAuthCredentialStore {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
;
;
;
;
;
[] SALT;
BuilderCodec<StoredCredentials> CREDENTIALS_CODEC;
Path path;
SecretKey encryptionKey;
IAuthCredentialStore. .OAuthTokens((String) , (String) , (Instant) );
UUID profile;
{
.path = path;
.encryptionKey = deriveKey();
( .encryptionKey == ) {
LOGGER.at(Level.WARNING).log( );
} {
.load();
}
}
SecretKey {
HardwareUtil.getUUID();
(hardwareId == ) {
;
} {
{
SecretKeyFactory.getInstance( );
(hardwareId.toString().toCharArray(), SALT, , );
factory.generateSecret(spec);
(tmp.getEncoded(), );
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
}
{
( .encryptionKey != && Files.exists( .path, [ ])) {
{
[] encrypted = Files.readAllBytes( .path);
[] decrypted = .decrypt(encrypted);
(decrypted == ) {
LOGGER.at(Level.WARNING).log( , .path);
;
}
BsonUtil.readFromBytes(decrypted);
(doc == ) {
LOGGER.at(Level.WARNING).log( , .path);
;
}
(StoredCredentials)CREDENTIALS_CODEC.decode(doc);
(stored != ) {
.tokens = .OAuthTokens(stored.accessToken, stored.refreshToken, stored.expiresAt);
.profile = stored.profileUuid;
}
LOGGER.at(Level.INFO).log( , .path);
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( , .path);
}
}
}
{
( .encryptionKey == ) {
LOGGER.at(Level.WARNING).log( );
} {
{
();
stored.accessToken = .tokens.accessToken();
stored.refreshToken = .tokens.refreshToken();
stored.expiresAt = .tokens.accessTokenExpiresAt();
stored.profileUuid = .profile;
(BsonDocument)CREDENTIALS_CODEC.encode(stored);
[] plaintext = BsonUtil.writeToBytes(doc);
[] encrypted = .encrypt(plaintext);
(encrypted == ) {
LOGGER.at(Level.SEVERE).log( );
;
}
Files.write( .path, encrypted, [ ]);
} (IOException e) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(e)).log( , .path);
}
}
}
[] encrypt( [] plaintext) {
( .encryptionKey == ) {
;
} {
{
[] iv = [ ];
( ()).nextBytes(iv);
Cipher.getInstance( );
cipher.init( , .encryptionKey, ( , iv));
[] ciphertext = cipher.doFinal(plaintext);
ByteBuffer.allocate(iv.length + ciphertext.length);
result.put(iv);
result.put(ciphertext);
result.array();
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(e)).log( );
;
}
}
}
[] decrypt( [] encrypted) {
( .encryptionKey != && encrypted.length >= ) {
{
ByteBuffer.wrap(encrypted);
[] iv = [ ];
buffer.get(iv);
[] ciphertext = [buffer.remaining()];
buffer.get(ciphertext);
Cipher.getInstance( );
cipher.init( , .encryptionKey, ( , iv));
cipher.doFinal(ciphertext);
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
} {
;
}
}
{
.tokens = tokens;
.save();
}
IAuthCredentialStore.OAuthTokens {
.tokens;
}
{
.profile = uuid;
.save();
}
UUID {
.profile;
}
{
.tokens = .OAuthTokens((String) , (String) , (Instant) );
.profile = ;
{
Files.deleteIfExists( .path);
} (IOException e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( , .path);
}
}
{
SALT = .getBytes(StandardCharsets.UTF_8);
CREDENTIALS_CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(StoredCredentials.class, StoredCredentials:: ).append( ( , Codec.STRING), (o, v) -> o.accessToken = v, (o) -> o.accessToken).add()).append( ( , Codec.STRING), (o, v) -> o.refreshToken = v, (o) -> o.refreshToken).add()).append( ( , Codec.INSTANT), (o, v) -> o.expiresAt = v, (o) -> o.expiresAt).add()).append( ( , Codec.UUID_STRING), (o, v) -> o.profileUuid = v, (o) -> o.profileUuid).add()).build();
}
{
String accessToken;
String refreshToken;
Instant expiresAt;
UUID profileUuid;
{
}
}
}
com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStoreProvider.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import java.nio.file.Path;
import javax.annotation.Nonnull;
public class EncryptedAuthCredentialStoreProvider implements AuthCredentialStoreProvider {
public static final String ID = "Encrypted" ;
public static final String DEFAULT_PATH = "auth.enc" ;
public static final BuilderCodec<EncryptedAuthCredentialStoreProvider> CODEC;
private String path = "auth.enc" ;
public EncryptedAuthCredentialStoreProvider () {
}
@Nonnull
public IAuthCredentialStore createStore () {
return new EncryptedAuthCredentialStore (Path.of(this .path));
}
@Nonnull
public String {
+ .path + ;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(EncryptedAuthCredentialStoreProvider.class, EncryptedAuthCredentialStoreProvider:: ).append( ( , Codec.STRING), (o, p) -> o.path = p, (o) -> o.path).add()).build();
}
}
com/hypixel/hytale/server/core/auth/IAuthCredentialStore.java
package com.hypixel.hytale.server.core.auth;
import java.time.Instant;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface IAuthCredentialStore {
void setTokens (@Nonnull OAuthTokens var1) ;
@Nonnull
OAuthTokens getTokens () ;
void setProfile (@Nullable UUID var1) ;
@Nullable
UUID getProfile () ;
void clear () ;
public static record OAuthTokens (@Nullable String accessToken, @Nullable String refreshToken, @Nullable Instant accessTokenExpiresAt) {
public boolean isValid () {
return this .refreshToken != null ;
}
}
}
com/hypixel/hytale/server/core/auth/JWTValidator.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.logger.HytaleLogger;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.crypto.Ed25519Verifier;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.OctetKeyPair;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import java.security.cert.X509Certificate;
import java.text.ParseException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class JWTValidator {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
private static final long CLOCK_SKEW_SECONDS = 300L ;
private static final JWSAlgorithm SUPPORTED_ALGORITHM;
private SessionServiceClient sessionServiceClient;
String expectedIssuer;
String expectedAudience;
JWKSet cachedJwkSet;
jwksCacheExpiry;
jwksCacheDurationMs;
ReentrantLock jwksFetchLock;
CompletableFuture<JWKSet> pendingFetch;
{
.jwksCacheDurationMs = TimeUnit.HOURS.toMillis( );
.jwksFetchLock = ();
.pendingFetch = ;
.sessionServiceClient = sessionServiceClient;
.expectedIssuer = expectedIssuer;
.expectedAudience = expectedAudience;
}
JWTClaims {
(accessToken.isEmpty()) {
LOGGER.at(Level.WARNING).log( );
;
} {
{
SignedJWT.parse(accessToken);
signedJWT.getHeader().getAlgorithm();
(!SUPPORTED_ALGORITHM.equals(algorithm)) {
LOGGER.at(Level.WARNING).log( , algorithm);
;
} (! .verifySignatureWithRetry(signedJWT)) {
LOGGER.at(Level.WARNING).log( );
;
} {
signedJWT.getJWTClaimsSet();
();
claims.issuer = claimsSet.getIssuer();
claims.audience = claimsSet.getAudience() != && !claimsSet.getAudience().isEmpty() ? (String)claimsSet.getAudience().get( ) : ;
claims.subject = claimsSet.getSubject();
claims.username = claimsSet.getStringClaim( );
claims.ipAddress = claimsSet.getStringClaim( );
claims.issuedAt = claimsSet.getIssueTime() != ? claimsSet.getIssueTime().toInstant().getEpochSecond() : ;
claims.expiresAt = claimsSet.getExpirationTime() != ? claimsSet.getExpirationTime().toInstant().getEpochSecond() : ;
claims.notBefore = claimsSet.getNotBeforeTime() != ? claimsSet.getNotBeforeTime().toInstant().getEpochSecond() : ;
Map<String, Object> cnfClaim = claimsSet.getJSONObjectClaim( );
(cnfClaim != ) {
claims.certificateFingerprint = (String)cnfClaim.get( );
}
(! .expectedIssuer.equals(claims.issuer)) {
LOGGER.at(Level.WARNING).log( , .expectedIssuer, claims.issuer);
;
} (! .expectedAudience.equals(claims.audience)) {
LOGGER.at(Level.WARNING).log( , .expectedAudience, claims.audience);
;
} {
Instant.now().getEpochSecond();
(claims.expiresAt != && nowSeconds >= claims.expiresAt + ) {
LOGGER.at(Level.WARNING).log( , claims.expiresAt, nowSeconds);
;
} (claims.notBefore != && nowSeconds < claims.notBefore - ) {
LOGGER.at(Level.WARNING).log( , claims.notBefore, nowSeconds);
;
} (claims.issuedAt != && claims.issuedAt > nowSeconds + ) {
LOGGER.at(Level.WARNING).log( , claims.issuedAt, nowSeconds);
;
} (!CertificateUtil.validateCertificateBinding(claims.certificateFingerprint, clientCert)) {
LOGGER.at(Level.WARNING).log( );
;
} {
LOGGER.at(Level.INFO).log( , claims.username, claims.subject);
claims;
}
}
}
} (ParseException e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
}
{
{
signedJWT.getHeader().getKeyID();
;
(JWK jwk : jwkSet.getKeys()) {
(jwk OctetKeyPair okp) {
(keyId == || keyId.equals(jwk.getKeyID())) {
ed25519Key = okp;
;
}
}
}
(ed25519Key == ) {
LOGGER.at(Level.WARNING).log( , keyId);
;
} {
(ed25519Key);
signedJWT.verify(verifier);
(valid) {
LOGGER.at(Level.FINE).log( , keyId);
}
valid;
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
JWKSet {
.getJwkSet( );
}
JWKSet {
System.currentTimeMillis();
(!forceRefresh && .cachedJwkSet != && now < .jwksCacheExpiry) {
.cachedJwkSet;
} {
.jwksFetchLock.lock();
JWKSet var4;
{
(forceRefresh || .cachedJwkSet == || now >= .jwksCacheExpiry) {
CompletableFuture<JWKSet> existing = .pendingFetch;
(existing != && !existing.isDone()) {
.jwksFetchLock.unlock();
{
(JWKSet)existing.join();
var5;
} {
.jwksFetchLock.lock();
}
}
(forceRefresh) {
LOGGER.at(Level.INFO).log( );
}
.pendingFetch = CompletableFuture.supplyAsync( ::fetchJwksFromService);
(JWKSet) .pendingFetch.join();
}
var4 = .cachedJwkSet;
} {
.jwksFetchLock.unlock();
}
var4;
}
}
JWKSet {
SessionServiceClient. .sessionServiceClient.getJwks();
(jwksResponse != && jwksResponse.keys != && jwksResponse.keys.length != ) {
{
ArrayList<JWK> jwkList = ();
(SessionServiceClient.JwkKey key : jwksResponse.keys) {
.convertToJWK(key);
(jwk != ) {
jwkList.add(jwk);
}
}
(jwkList.isEmpty()) {
LOGGER.at(Level.WARNING).log( );
.cachedJwkSet;
} {
(jwkList);
.cachedJwkSet = newSet;
.jwksCacheExpiry = System.currentTimeMillis() + .jwksCacheDurationMs;
LOGGER.at(Level.INFO).log( , jwkList.size());
newSet;
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
.cachedJwkSet;
}
} {
LOGGER.at(Level.WARNING).log( );
.cachedJwkSet;
}
}
{
.getJwkSet();
(jwkSet == ) {
;
} ( .verifySignature(signedJWT, jwkSet)) {
;
} {
LOGGER.at(Level.INFO).log( );
.getJwkSet( );
freshJwkSet != && freshJwkSet != jwkSet ? .verifySignature(signedJWT, freshJwkSet) : ;
}
}
JWK {
(! .equals(key.kty)) {
LOGGER.at(Level.WARNING).log( , key.kty);
;
} {
{
String.format( , key.crv, key.x, key.kid);
JWK.parse(json);
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
}
{
.jwksFetchLock.lock();
{
.cachedJwkSet = ;
.jwksCacheExpiry = ;
.pendingFetch = ;
} {
.jwksFetchLock.unlock();
}
}
IdentityTokenClaims {
(identityToken.isEmpty()) {
LOGGER.at(Level.WARNING).log( );
;
} {
{
SignedJWT.parse(identityToken);
signedJWT.getHeader().getAlgorithm();
(!SUPPORTED_ALGORITHM.equals(algorithm)) {
LOGGER.at(Level.WARNING).log( , algorithm);
;
} (! .verifySignatureWithRetry(signedJWT)) {
LOGGER.at(Level.WARNING).log( );
;
} {
signedJWT.getJWTClaimsSet();
();
claims.issuer = claimsSet.getIssuer();
claims.subject = claimsSet.getSubject();
claims.username = claimsSet.getStringClaim( );
claims.issuedAt = claimsSet.getIssueTime() != ? claimsSet.getIssueTime().toInstant().getEpochSecond() : ;
claims.expiresAt = claimsSet.getExpirationTime() != ? claimsSet.getExpirationTime().toInstant().getEpochSecond() : ;
claims.notBefore = claimsSet.getNotBeforeTime() != ? claimsSet.getNotBeforeTime().toInstant().getEpochSecond() : ;
claims.scope = claimsSet.getStringClaim( );
(! .expectedIssuer.equals(claims.issuer)) {
LOGGER.at(Level.WARNING).log( , .expectedIssuer, claims.issuer);
;
} {
Instant.now().getEpochSecond();
(claims.expiresAt == ) {
LOGGER.at(Level.WARNING).log( );
;
} (nowSeconds >= claims.expiresAt + ) {
LOGGER.at(Level.WARNING).log( , claims.expiresAt, nowSeconds);
;
} (claims.notBefore != && nowSeconds < claims.notBefore - ) {
LOGGER.at(Level.WARNING).log( , claims.notBefore, nowSeconds);
;
} (claims.issuedAt != && claims.issuedAt > nowSeconds + ) {
LOGGER.at(Level.WARNING).log( , claims.issuedAt, nowSeconds);
;
} (claims.getSubjectAsUUID() == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
LOGGER.at(Level.INFO).log( , claims.username, claims.subject);
claims;
}
}
}
} (ParseException e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
}
SessionTokenClaims {
(sessionToken.isEmpty()) {
LOGGER.at(Level.WARNING).log( );
;
} {
{
SignedJWT.parse(sessionToken);
signedJWT.getHeader().getAlgorithm();
(!SUPPORTED_ALGORITHM.equals(algorithm)) {
LOGGER.at(Level.WARNING).log( , algorithm);
;
} (! .verifySignatureWithRetry(signedJWT)) {
LOGGER.at(Level.WARNING).log( );
;
} {
signedJWT.getJWTClaimsSet();
();
claims.issuer = claimsSet.getIssuer();
claims.subject = claimsSet.getSubject();
claims.issuedAt = claimsSet.getIssueTime() != ? claimsSet.getIssueTime().toInstant().getEpochSecond() : ;
claims.expiresAt = claimsSet.getExpirationTime() != ? claimsSet.getExpirationTime().toInstant().getEpochSecond() : ;
claims.notBefore = claimsSet.getNotBeforeTime() != ? claimsSet.getNotBeforeTime().toInstant().getEpochSecond() : ;
(! .expectedIssuer.equals(claims.issuer)) {
LOGGER.at(Level.WARNING).log( , .expectedIssuer, claims.issuer);
;
} {
Instant.now().getEpochSecond();
(claims.expiresAt == ) {
LOGGER.at(Level.WARNING).log( );
;
} (nowSeconds >= claims.expiresAt + ) {
LOGGER.at(Level.WARNING).log( , claims.expiresAt, nowSeconds);
;
} (claims.notBefore != && nowSeconds < claims.notBefore - ) {
LOGGER.at(Level.WARNING).log( , claims.notBefore, nowSeconds);
;
} (claims.issuedAt != && claims.issuedAt > nowSeconds + ) {
LOGGER.at(Level.WARNING).log( , claims.issuedAt, nowSeconds);
;
} {
LOGGER.at(Level.INFO).log( );
claims;
}
}
}
} (ParseException e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
}
{
SUPPORTED_ALGORITHM = JWSAlgorithm.EdDSA;
}
{
String issuer;
String subject;
Long issuedAt;
Long expiresAt;
Long notBefore;
{
}
}
{
String issuer;
String subject;
String username;
Long issuedAt;
Long expiresAt;
Long notBefore;
String scope;
{
}
UUID {
( .subject == ) {
;
} {
{
UUID.fromString( .subject);
} (IllegalArgumentException var2) {
;
}
}
}
String[] getScopes() {
.scope != && ! .scope.isEmpty() ? .scope.split( ) : [ ];
}
{
(String s : .getScopes()) {
(s.equals(targetScope)) {
;
}
}
;
}
}
{
String issuer;
String audience;
String subject;
String username;
String ipAddress;
Long issuedAt;
Long expiresAt;
Long notBefore;
String certificateFingerprint;
{
}
UUID {
( .subject == ) {
;
} {
{
UUID.fromString( .subject);
} (IllegalArgumentException var2) {
;
}
}
}
}
}
com/hypixel/hytale/server/core/auth/MemoryAuthCredentialStoreProvider.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
public class MemoryAuthCredentialStoreProvider implements AuthCredentialStoreProvider {
public static final String ID = "Memory" ;
public static final BuilderCodec<MemoryAuthCredentialStoreProvider> CODEC = BuilderCodec.builder(MemoryAuthCredentialStoreProvider.class, MemoryAuthCredentialStoreProvider::new ).build();
public MemoryAuthCredentialStoreProvider () {
}
@Nonnull
public IAuthCredentialStore createStore () {
return new DefaultAuthCredentialStore ();
}
@Nonnull
public String toString () {
return "MemoryAuthCredentialStoreProvider{}" ;
}
}
com/hypixel/hytale/server/core/auth/PlayerAuthentication.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.protocol.HostAddress;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PlayerAuthentication {
public static final int MAX_REFERRAL_DATA_SIZE = 4096 ;
private UUID uuid;
private String username;
private byte [] referralData;
private HostAddress referralSource;
public PlayerAuthentication () {
}
public PlayerAuthentication (@Nonnull UUID uuid, @Nonnull String username) {
this .uuid = uuid;
this .username = username;
}
@Nonnull
public String getUsername () {
if (this .username == null ) {
throw new UnsupportedOperationException ("Username not set - incomplete authentication" );
} else {
return this .username;
}
}
@Nonnull
UUID {
( .uuid == ) {
( );
} {
.uuid;
}
}
{
.username = username;
}
{
.uuid = uuid;
}
[] getReferralData() {
.referralData;
}
{
(referralData != && referralData.length > ) {
( + referralData.length + );
} {
.referralData = referralData;
}
}
HostAddress {
.referralSource;
}
{
.referralSource = referralSource;
}
}
com/hypixel/hytale/server/core/auth/ProfileServiceClient.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.EmptyExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.logger.HytaleLogger;
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ProfileServiceClient {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
private static final Duration REQUEST_TIMEOUT = Duration.ofSeconds(5L );
private final HttpClient httpClient;
private final String profileServiceUrl;
{
(profileServiceUrl != && !profileServiceUrl.isEmpty()) {
.profileServiceUrl = profileServiceUrl.endsWith( ) ? profileServiceUrl.substring( , profileServiceUrl.length() - ) : profileServiceUrl;
.httpClient = HttpClient.newBuilder().connectTimeout(REQUEST_TIMEOUT).build();
LOGGER.at(Level.INFO).log( , .profileServiceUrl);
} {
( );
}
}
PublicGameProfile {
{
HttpRequest. HttpRequest.newBuilder();
.profileServiceUrl;
var10000.uri(URI.create(var10001 + + uuid.toString())).header( , ).header( , + bearerToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).GET().build();
LOGGER.at(Level.FINE).log( , uuid);
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
ProfileServiceClient.PublicGameProfile.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(profile == ) {
LOGGER.at(Level.WARNING).log( , uuid);
;
} {
LOGGER.at(Level.FINE).log( , profile.getUsername(), profile.getUuid());
profile;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var7) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
}
CompletableFuture<PublicGameProfile> {
CompletableFuture.supplyAsync(() -> .getProfileByUuid(uuid, bearerToken));
}
PublicGameProfile {
{
URLEncoder.encode(username, StandardCharsets.UTF_8);
HttpRequest.newBuilder().uri(URI.create( .profileServiceUrl + + encodedUsername)).header( , ).header( , + bearerToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).GET().build();
LOGGER.at(Level.FINE).log( , username);
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
ProfileServiceClient.PublicGameProfile.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(profile == ) {
LOGGER.at(Level.WARNING).log( , username);
;
} {
LOGGER.at(Level.FINE).log( , profile.getUsername(), profile.getUuid());
profile;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var8) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
}
CompletableFuture<PublicGameProfile> {
CompletableFuture.supplyAsync(() -> .getProfileByUsername(username, bearerToken));
}
<T> KeyedCodec<T> {
<T>(key, codec, , );
}
{
BuilderCodec<PublicGameProfile> CODEC;
UUID uuid;
String username;
{
}
{
.uuid = uuid;
.username = username;
}
UUID {
.uuid;
}
String {
.username;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(PublicGameProfile.class, PublicGameProfile:: ).append(ProfileServiceClient.externalKey( , Codec.UUID_STRING), (p, v) -> p.uuid = v, PublicGameProfile::getUuid).add()).append(ProfileServiceClient.externalKey( , Codec.STRING), (p, v) -> p.username = v, PublicGameProfile::getUsername).add()).build();
}
}
}
com/hypixel/hytale/server/core/auth/ServerAuthManager.java
package com.hypixel.hytale.server.core.auth;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.hypixel.hytale.codec.lookup.Priority;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.Options;
import com.hypixel.hytale.server.core.auth.oauth.OAuthBrowserFlow;
import com.hypixel.hytale.server.core.auth.oauth.OAuthClient;
import com.hypixel.hytale.server.core.auth.oauth.OAuthDeviceFlow;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.time.Instant;
import java.util.Base64;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import joptsimple.OptionSet;
public class ServerAuthManager {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
;
ServerAuthManager instance;
AuthMode authMode;
Instant tokenExpiry;
AtomicReference<SessionServiceClient.GameSessionResponse> gameSession;
AtomicReference<IAuthCredentialStore> credentialStore;
Map<UUID, SessionServiceClient.GameProfile> availableProfiles;
SessionServiceClient.GameProfile[] pendingProfiles;
AuthMode pendingAuthMode;
AtomicReference<X509Certificate> serverCertificate;
UUID serverSessionId;
isSingleplayer;
OAuthClient oauthClient;
SessionServiceClient sessionServiceClient;
ProfileServiceClient profileServiceClient;
ScheduledExecutorService refreshScheduler;
ScheduledFuture<?> refreshTask;
Runnable cancelActiveFlow;
{
.authMode = ServerAuthManager.AuthMode.NONE;
.gameSession = ();
.credentialStore = ( ());
.availableProfiles = ();
.serverCertificate = ();
.serverSessionId = UUID.randomUUID();
.refreshScheduler = Executors.newSingleThreadScheduledExecutor((r) -> {
(r, );
t.setDaemon( );
t;
});
}
ServerAuthManager {
(instance == ) {
(ServerAuthManager.class) {
(instance == ) {
instance = ();
}
}
}
instance;
}
ProfileServiceClient {
( .profileServiceClient == ) {
( ) {
( .profileServiceClient == ) {
.profileServiceClient = ( );
}
}
}
.profileServiceClient;
}
{
Options.getOptionSet();
(optionSet == ) {
LOGGER.at(Level.WARNING).log( );
} {
.oauthClient = ();
.isSingleplayer = optionSet.has(Options.SINGLEPLAYER);
( .isSingleplayer && optionSet.has(Options.OWNER_UUID)) {
SessionServiceClient. .GameProfile();
ownerProfile.uuid = (UUID)optionSet.valueOf(Options.OWNER_UUID);
ownerProfile.username = optionSet.has(Options.OWNER_NAME) ? (String)optionSet.valueOf(Options.OWNER_NAME) : ;
((IAuthCredentialStore) .credentialStore.get()).setProfile(ownerProfile.uuid);
LOGGER.at(Level.INFO).log( , ownerProfile.username, ownerProfile.uuid);
}
;
;
;
(optionSet.has(Options.SESSION_TOKEN)) {
sessionTokenValue = (String)optionSet.valueOf(Options.SESSION_TOKEN);
LOGGER.at(Level.INFO).log( );
} {
System.getenv( );
(envToken != && !envToken.isEmpty()) {
sessionTokenValue = envToken;
LOGGER.at(Level.INFO).log( );
}
}
(optionSet.has(Options.IDENTITY_TOKEN)) {
identityTokenValue = (String)optionSet.valueOf(Options.IDENTITY_TOKEN);
LOGGER.at(Level.INFO).log( );
} {
System.getenv( );
(envToken != && !envToken.isEmpty()) {
identityTokenValue = envToken;
LOGGER.at(Level.INFO).log( );
}
}
(sessionTokenValue != || identityTokenValue != ) {
( .validateInitialTokens(sessionTokenValue, identityTokenValue)) {
SessionServiceClient. .GameSessionResponse();
session.sessionToken = sessionTokenValue;
session.identityToken = identityTokenValue;
.gameSession.set(session);
hasCliTokens = ;
} {
LOGGER.at(Level.WARNING).log( );
}
}
(hasCliTokens) {
( .isSingleplayer) {
.authMode = ServerAuthManager.AuthMode.SINGLEPLAYER;
LOGGER.at(Level.INFO).log( );
} {
.authMode = ServerAuthManager.AuthMode.EXTERNAL_SESSION;
LOGGER.at(Level.INFO).log( );
}
.parseAndScheduleRefresh();
} {
LOGGER.at(Level.INFO).log( );
}
LOGGER.at(Level.INFO).log( , .serverSessionId);
LOGGER.at(Level.FINE).log( , .hasSessionToken() ? : , .hasIdentityToken() ? : , .authMode);
}
}
{
HytaleServer.get().getConfig().getAuthCredentialStoreProvider();
.credentialStore.set(provider.createStore());
LOGGER.at(Level.INFO).log( , AuthCredentialStoreProvider.CODEC.getIdFor(provider.getClass()));
(IAuthCredentialStore) .credentialStore.get();
IAuthCredentialStore. store.getTokens();
(tokens.isValid()) {
LOGGER.at(Level.INFO).log( );
.createGameSessionFromOAuth(ServerAuthManager.AuthMode.OAUTH_STORE);
(result == ServerAuthManager.AuthResult.SUCCESS) {
LOGGER.at(Level.INFO).log( );
} (result == ServerAuthManager.AuthResult.PENDING_PROFILE_SELECTION) {
LOGGER.at(Level.INFO).log( );
} {
LOGGER.at(Level.WARNING).log( );
}
}
}
{
.cancelActiveFlow();
( .refreshTask != ) {
.refreshTask.cancel( );
}
.refreshScheduler.shutdown();
.getSessionToken();
(currentSessionToken != && !currentSessionToken.isEmpty()) {
( .sessionServiceClient == ) {
.sessionServiceClient = ( );
}
.sessionServiceClient.terminateSession(currentSessionToken);
}
}
{
.cancelActiveFlow();
( .refreshTask != ) {
.refreshTask.cancel( );
.refreshTask = ;
}
.gameSession.set((Object) );
((IAuthCredentialStore) .credentialStore.get()).clear();
.availableProfiles.clear();
.pendingProfiles = ;
.pendingAuthMode = ;
.tokenExpiry = ;
.authMode = ServerAuthManager.AuthMode.NONE;
LOGGER.at(Level.INFO).log( );
}
SessionServiceClient.GameSessionResponse {
(SessionServiceClient.GameSessionResponse) .gameSession.get();
}
{
.gameSession.set(session);
LOGGER.at(Level.FINE).log( );
}
String {
SessionServiceClient. (SessionServiceClient.GameSessionResponse) .gameSession.get();
session != ? session.identityToken : ;
}
String {
SessionServiceClient. (SessionServiceClient.GameSessionResponse) .gameSession.get();
session != ? session.sessionToken : ;
}
{
SessionServiceClient. (SessionServiceClient.GameSessionResponse) .gameSession.get();
session != && session.identityToken != ;
}
{
SessionServiceClient. (SessionServiceClient.GameSessionResponse) .gameSession.get();
session != && session.sessionToken != ;
}
{
.serverCertificate.set(certificate);
LOGGER.at(Level.INFO).log( , certificate.getSubjectX500Principal());
}
X509Certificate {
(X509Certificate) .serverCertificate.get();
}
String {
(X509Certificate) .serverCertificate.get();
cert == ? : CertificateUtil.computeCertificateFingerprint(cert);
}
UUID {
.serverSessionId;
}
AuthMode {
.authMode;
}
{
.isSingleplayer;
}
{
((IAuthCredentialStore) .credentialStore.get()).getProfile();
profileUuid != && profileUuid.equals(playerUuid);
}
SessionServiceClient.GameProfile {
((IAuthCredentialStore) .credentialStore.get()).getProfile();
profileUuid == ? : (SessionServiceClient.GameProfile) .availableProfiles.get(profileUuid);
}
Instant {
.tokenExpiry;
}
String {
();
sb.append( .authMode.name());
( .hasSessionToken() && .hasIdentityToken()) {
sb.append( );
} (! .hasSessionToken() && ! .hasIdentityToken()) {
sb.append( );
} {
sb.append( );
}
( .tokenExpiry != ) {
.tokenExpiry.getEpochSecond() - Instant.now().getEpochSecond();
(secondsRemaining > ) {
sb.append(String.format( , secondsRemaining / , secondsRemaining % ));
} {
sb.append( );
}
}
sb.toString();
}
CompletableFuture<AuthResult> {
( .isSingleplayer) {
CompletableFuture.completedFuture(ServerAuthManager.AuthResult.FAILED);
} {
.cancelActiveFlow();
.cancelActiveFlow = .oauthClient.startFlow(flow);
flow.getFuture().thenApply((res) -> {
(res) {
SUCCESS:
(IAuthCredentialStore) .credentialStore.get();
OAuthClient. flow.getTokenResponse();
store.setTokens( .OAuthTokens(tokens.accessToken(), tokens.refreshToken(), Instant.now().plusSeconds(( )tokens.expiresIn())));
.createGameSessionFromOAuth(ServerAuthManager.AuthMode.OAUTH_BROWSER);
FAILED:
LOGGER.at(Level.WARNING).log( , flow.getErrorMessage());
ServerAuthManager.AuthResult.FAILED;
:
LOGGER.at(Level.WARNING).log( , res);
ServerAuthManager.AuthResult.FAILED;
}
});
}
}
CompletableFuture<AuthResult> {
( .isSingleplayer) {
CompletableFuture.completedFuture(ServerAuthManager.AuthResult.FAILED);
} {
.cancelActiveFlow();
.cancelActiveFlow = .oauthClient.startFlow(flow);
flow.getFuture().thenApply((res) -> {
(res) {
SUCCESS:
(IAuthCredentialStore) .credentialStore.get();
OAuthClient. flow.getTokenResponse();
store.setTokens( .OAuthTokens(tokens.accessToken(), tokens.refreshToken(), Instant.now().plusSeconds(( )tokens.expiresIn())));
.createGameSessionFromOAuth(ServerAuthManager.AuthMode.OAUTH_DEVICE);
FAILED:
LOGGER.at(Level.WARNING).log( , flow.getErrorMessage());
ServerAuthManager.AuthResult.FAILED;
:
LOGGER.at(Level.WARNING).log( , res);
ServerAuthManager.AuthResult.FAILED;
}
});
}
}
CompletableFuture<AuthResult> {
( .isSingleplayer) {
CompletableFuture.completedFuture(ServerAuthManager.AuthResult.FAILED);
} ( .hasSessionToken() && .hasIdentityToken()) {
CompletableFuture.completedFuture(ServerAuthManager.AuthResult.FAILED);
} {
.credentialStore.set(store);
CompletableFuture.completedFuture( .createGameSessionFromOAuth(ServerAuthManager.AuthMode.OAUTH_STORE));
}
}
{
(IAuthCredentialStore) .credentialStore.get();
provider.createStore();
IAuthCredentialStore. oldStore.getTokens();
(tokens.isValid()) {
newStore.setTokens(tokens);
}
oldStore.getProfile();
(profile != ) {
newStore.setProfile(profile);
}
.credentialStore.set(newStore);
LOGGER.at(Level.INFO).log( , provider.getClass().getSimpleName());
}
{
( .cancelActiveFlow != ) {
.cancelActiveFlow.run();
.cancelActiveFlow = ;
;
} {
;
}
}
SessionServiceClient.GameProfile[] getPendingProfiles() {
.pendingProfiles;
}
{
.pendingProfiles != && .pendingProfiles.length > ;
}
{
SessionServiceClient.GameProfile[] profiles = .pendingProfiles;
.pendingAuthMode;
(profiles != && profiles.length != ) {
(index >= && index <= profiles.length) {
SessionServiceClient. profiles[index - ];
LOGGER.at(Level.INFO).log( , selected.username, selected.uuid);
.completeAuthWithProfile(selected, mode != ? mode : ServerAuthManager.AuthMode.OAUTH_BROWSER);
} {
LOGGER.at(Level.WARNING).log( , index, profiles.length);
;
}
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
{
SessionServiceClient.GameProfile[] profiles = .pendingProfiles;
.pendingAuthMode;
(profiles != && profiles.length != ) {
(SessionServiceClient.GameProfile profile : profiles) {
(profile.username != && profile.username.equalsIgnoreCase(username)) {
LOGGER.at(Level.INFO).log( , profile.username, profile.uuid);
.completeAuthWithProfile(profile, mode != ? mode : ServerAuthManager.AuthMode.OAUTH_BROWSER);
}
}
LOGGER.at(Level.WARNING).log( , username);
;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
{
.pendingProfiles = ;
.pendingAuthMode = ;
}
{
(sessionToken == && identityToken == ) {
;
} {
( .sessionServiceClient == ) {
.sessionServiceClient = ( );
}
( .sessionServiceClient, , );
;
(identityToken != ) {
JWTValidator. validator.validateIdentityToken(identityToken);
(claims == ) {
LOGGER.at(Level.WARNING).log( );
valid = ;
} (!claims.hasScope( )) {
LOGGER.at(Level.WARNING).log( , , claims.scope);
valid = ;
} {
LOGGER.at(Level.INFO).log( , claims.username, claims.subject);
}
}
(sessionToken != ) {
JWTValidator. validator.validateSessionToken(sessionToken);
(claims == ) {
LOGGER.at(Level.WARNING).log( );
valid = ;
} {
LOGGER.at(Level.INFO).log( );
}
}
valid;
}
}
AuthResult {
(! .refreshOAuthTokens()) {
LOGGER.at(Level.WARNING).log( );
ServerAuthManager.AuthResult.FAILED;
} {
(IAuthCredentialStore) .credentialStore.get();
store.getTokens().accessToken();
(accessToken == ) {
LOGGER.at(Level.WARNING).log( );
ServerAuthManager.AuthResult.FAILED;
} {
( .sessionServiceClient == ) {
.sessionServiceClient = ( );
}
SessionServiceClient.GameProfile[] profiles = .sessionServiceClient.getGameProfiles(accessToken);
(profiles != && profiles.length != ) {
.availableProfiles.clear();
(SessionServiceClient.GameProfile profile : profiles) {
.availableProfiles.put(profile.uuid, profile);
}
SessionServiceClient. .tryAutoSelectProfile(profiles);
(profile != ) {
.completeAuthWithProfile(profile, mode) ? ServerAuthManager.AuthResult.SUCCESS : ServerAuthManager.AuthResult.FAILED;
} {
.pendingProfiles = profiles;
.pendingAuthMode = mode;
.cancelActiveFlow = ;
LOGGER.at(Level.INFO).log( );
( ; i < profiles.length; ++i) {
LOGGER.at(Level.INFO).log( , i + , profiles[i].username, profiles[i].uuid);
}
ServerAuthManager.AuthResult.PENDING_PROFILE_SELECTION;
}
} {
LOGGER.at(Level.WARNING).log( );
ServerAuthManager.AuthResult.FAILED;
}
}
}
}
{
.refreshOAuthTokens( );
}
{
(IAuthCredentialStore) .credentialStore.get();
IAuthCredentialStore. store.getTokens();
tokens.accessTokenExpiresAt();
(!force && expiresAt != && !expiresAt.isBefore(Instant.now().plusSeconds( ))) {
;
} {
tokens.refreshToken();
(refreshToken == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
LOGGER.at(Level.INFO).log( );
OAuthClient. .oauthClient.refreshTokens(refreshToken);
(newTokens != && newTokens.isSuccess()) {
store.setTokens( .OAuthTokens(newTokens.accessToken(), newTokens.refreshToken(), Instant.now().plusSeconds(( )newTokens.expiresIn())));
;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
}
}
SessionServiceClient.GameProfile {
Options.getOptionSet();
(optionSet != && optionSet.has(Options.OWNER_UUID)) {
(UUID)optionSet.valueOf(Options.OWNER_UUID);
(SessionServiceClient.GameProfile profile : profiles) {
(profile.uuid.equals(requestedUuid)) {
LOGGER.at(Level.INFO).log( , profile.username, profile.uuid);
profile;
}
}
LOGGER.at(Level.WARNING).log( , requestedUuid);
;
} (profiles.length == ) {
LOGGER.at(Level.INFO).log( , profiles[ ].username, profiles[ ].uuid);
profiles[ ];
} {
((IAuthCredentialStore) .credentialStore.get()).getProfile();
(profileUuid != ) {
(SessionServiceClient.GameProfile profile : profiles) {
(profile.uuid.equals(profileUuid)) {
LOGGER.at(Level.INFO).log( , profile.username, profile.uuid);
profile;
}
}
}
;
}
}
{
SessionServiceClient. .createGameSession(profile.uuid);
(newSession == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
.gameSession.set(newSession);
.authMode = mode;
.cancelActiveFlow = ;
.pendingProfiles = ;
.pendingAuthMode = ;
.getEffectiveExpiry(newSession);
(effectiveExpiry != ) {
.setExpiryAndScheduleRefresh(effectiveExpiry);
}
LOGGER.at(Level.INFO).log( , mode);
;
}
}
SessionServiceClient.GameSessionResponse {
( .sessionServiceClient == ) {
.sessionServiceClient = ( );
}
(! .refreshOAuthTokens()) {
LOGGER.at(Level.WARNING).log( );
;
} {
(IAuthCredentialStore) .credentialStore.get();
store.getTokens().accessToken();
SessionServiceClient. .sessionServiceClient.createGameSession(accessToken, profileUuid);
(result == ) {
LOGGER.at(Level.WARNING).log( );
(! .refreshOAuthTokens( )) {
LOGGER.at(Level.WARNING).log( );
;
}
result = .sessionServiceClient.createGameSession(accessToken, profileUuid);
(result == ) {
LOGGER.at(Level.WARNING).log( );
;
}
}
store.setProfile(profileUuid);
result;
}
}
{
SessionServiceClient. (SessionServiceClient.GameSessionResponse) .gameSession.get();
.getEffectiveExpiry(session);
(effectiveExpiry != ) {
.setExpiryAndScheduleRefresh(effectiveExpiry);
}
}
Instant {
session != ? session.getExpiresAtInstant() : ;
.parseIdentityTokenExpiry(session != ? session.identityToken : .getIdentityToken());
(sessionExpiry != && identityExpiry != ) {
sessionExpiry.isBefore(identityExpiry) ? sessionExpiry : identityExpiry;
} {
sessionExpiry != ? sessionExpiry : identityExpiry;
}
}
Instant {
(idToken == ) {
;
} {
{
String[] parts = idToken.split( );
(parts.length != ) {
;
}
(Base64.getUrlDecoder().decode(parts[ ]), StandardCharsets.UTF_8);
JsonParser.parseString(payload).getAsJsonObject();
(json.has( )) {
Instant.ofEpochSecond(json.get( ).getAsLong());
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
}
;
}
}
{
.tokenExpiry = expiry;
( .refreshTask != ) {
.refreshTask.cancel( );
}
expiry.getEpochSecond() - Instant.now().getEpochSecond();
(secondsUntilExpiry > ) {
Math.max(secondsUntilExpiry - , );
LOGGER.at(Level.INFO).log( , refreshDelay);
.refreshTask = .refreshScheduler.schedule( ::doRefresh, refreshDelay, TimeUnit.SECONDS);
}
}
{
.getSessionToken();
(currentSessionToken == || ! .refreshGameSession(currentSessionToken)) {
LOGGER.at(Level.INFO).log( );
(! .refreshGameSessionViaOAuth()) {
LOGGER.at(Level.WARNING).log( );
}
}
}
{
LOGGER.at(Level.INFO).log( );
( .sessionServiceClient == ) {
.sessionServiceClient = ( );
}
{
SessionServiceClient. (SessionServiceClient.GameSessionResponse) .sessionServiceClient.refreshSessionAsync(currentSessionToken).join();
(response != ) {
.gameSession.set(response);
.getEffectiveExpiry(response);
(effectiveExpiry != ) {
.setExpiryAndScheduleRefresh(effectiveExpiry);
}
LOGGER.at(Level.INFO).log( );
;
}
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
}
;
}
{
var10000;
( .authMode.ordinal()) {
:
:
:
var10000 = ;
;
:
var10000 = ;
}
var10000;
(!supported) {
LOGGER.at(Level.WARNING).log( );
;
} {
((IAuthCredentialStore) .credentialStore.get()).getProfile();
(currentProfile == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
SessionServiceClient. .createGameSession(currentProfile);
(newSession == ) {
LOGGER.at(Level.WARNING).log( );
;
} {
.gameSession.set(newSession);
.getEffectiveExpiry(newSession);
(effectiveExpiry != ) {
.setExpiryAndScheduleRefresh(effectiveExpiry);
}
LOGGER.at(Level.INFO).log( );
;
}
}
}
}
{
AuthCredentialStoreProvider.CODEC.register(Priority.DEFAULT, , MemoryAuthCredentialStoreProvider.class, MemoryAuthCredentialStoreProvider.CODEC);
AuthCredentialStoreProvider.CODEC.register( , EncryptedAuthCredentialStoreProvider.class, EncryptedAuthCredentialStoreProvider.CODEC);
}
{
NONE,
SINGLEPLAYER,
EXTERNAL_SESSION,
OAUTH_BROWSER,
OAUTH_DEVICE,
OAUTH_STORE;
{
}
}
{
SUCCESS,
PENDING_PROFILE_SELECTION,
FAILED;
{
}
}
}
com/hypixel/hytale/server/core/auth/SessionServiceClient.java
package com.hypixel.hytale.server.core.auth;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.EmptyExtraInfo;
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.util.RawJsonReader;
import com.hypixel.hytale.logger.HytaleLogger;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.time.Instant;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class SessionServiceClient {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
private static final Duration REQUEST_TIMEOUT = Duration.ofSeconds(5L );
private final HttpClient httpClient;
String sessionServiceUrl;
{
(sessionServiceUrl != && !sessionServiceUrl.isEmpty()) {
.sessionServiceUrl = sessionServiceUrl.endsWith( ) ? sessionServiceUrl.substring( , sessionServiceUrl.length() - ) : sessionServiceUrl;
.httpClient = HttpClient.newBuilder().connectTimeout(REQUEST_TIMEOUT).build();
LOGGER.at(Level.INFO).log( , .sessionServiceUrl);
} {
( );
}
}
CompletableFuture<String> {
CompletableFuture.supplyAsync(() -> {
{
String.format( , escapeJsonString(identityToken), escapeJsonString(serverAudience));
HttpRequest.newBuilder().uri(URI.create( .sessionServiceUrl + )).header( , ).header( , ).header( , + bearerToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).POST(BodyPublishers.ofString(jsonBody)).build();
LOGGER.at(Level.INFO).log( , serverAudience);
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
SessionServiceClient.AuthGrantResponse.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(authGrantResponse != && authGrantResponse.authorizationGrant != ) {
LOGGER.at(Level.INFO).log( );
authGrantResponse.authorizationGrant;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var9) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
});
}
CompletableFuture<String> {
CompletableFuture.supplyAsync(() -> {
{
String.format( , escapeJsonString(authorizationGrant), escapeJsonString(x509Fingerprint));
HttpRequest.newBuilder().uri(URI.create( .sessionServiceUrl + )).header( , ).header( , ).header( , + bearerToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).POST(BodyPublishers.ofString(jsonBody)).build();
LOGGER.at(Level.INFO).log( );
LOGGER.at(Level.FINE).log( , bearerToken.length() > ? bearerToken.substring( , ) : bearerToken);
LOGGER.at(Level.FINE).log( , jsonBody);
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
SessionServiceClient.AccessTokenResponse.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(tokenResponse != && tokenResponse.accessToken != ) {
LOGGER.at(Level.INFO).log( );
tokenResponse.accessToken;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var9) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
});
}
JwksResponse {
{
HttpRequest.newBuilder().uri(URI.create( .sessionServiceUrl + )).header( , ).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).GET().build();
LOGGER.at(Level.FINE).log( );
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
SessionServiceClient.JwksResponse.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(jwks != && jwks.keys != && jwks.keys.length != ) {
LOGGER.at(Level.INFO).log( , jwks.keys.length);
jwks;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var5) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
}
GameProfile[] getGameProfiles( String oauthAccessToken) {
{
HttpRequest.newBuilder().uri(URI.create( )).header( , ).header( , + oauthAccessToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).GET().build();
LOGGER.at(Level.INFO).log( );
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
SessionServiceClient.LauncherDataResponse.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(data != && data.profiles != ) {
LOGGER.at(Level.INFO).log( , data.profiles.length);
data.profiles;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var6) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
}
GameSessionResponse {
{
String.format( , profileUuid.toString());
HttpRequest.newBuilder().uri(URI.create( .sessionServiceUrl + )).header( , ).header( , + oauthAccessToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).POST(BodyPublishers.ofString(body)).build();
LOGGER.at(Level.INFO).log( );
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != && response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
SessionServiceClient.GameSessionResponse.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(sessionResponse != && sessionResponse.identityToken != ) {
LOGGER.at(Level.INFO).log( );
sessionResponse;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var8) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
}
CompletableFuture<GameSessionResponse> {
CompletableFuture.supplyAsync(() -> {
{
HttpRequest.newBuilder().uri(URI.create( .sessionServiceUrl + )).header( , ).header( , + sessionToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).POST(BodyPublishers.noBody()).build();
LOGGER.at(Level.INFO).log( );
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
SessionServiceClient.GameSessionResponse.CODEC.decodeJson( (((String)response.body()).toCharArray()), EmptyExtraInfo.EMPTY);
(sessionResponse != && sessionResponse.identityToken != ) {
LOGGER.at(Level.INFO).log( );
sessionResponse;
} {
LOGGER.at(Level.WARNING).log( );
;
}
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
} (InterruptedException var6) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
;
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
;
}
});
}
{
(sessionToken != && !sessionToken.isEmpty()) {
{
HttpRequest.newBuilder().uri(URI.create( .sessionServiceUrl + )).header( , + sessionToken).header( , AuthConfig.USER_AGENT).timeout(REQUEST_TIMEOUT).DELETE().build();
LOGGER.at(Level.INFO).log( );
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != && response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
} {
LOGGER.at(Level.INFO).log( );
}
} (IOException e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
} (InterruptedException var5) {
LOGGER.at(Level.WARNING).log( );
Thread.currentThread().interrupt();
} (Exception e) {
LOGGER.at(Level.WARNING).log( , e.getMessage());
}
}
}
String {
value == ? : value.replace( , ).replace( , ).replace( , ).replace( , ).replace( , );
}
<T> KeyedCodec<T> {
<T>(key, codec, , );
}
{
String authorizationGrant;
BuilderCodec<AuthGrantResponse> CODEC;
{
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(AuthGrantResponse.class, AuthGrantResponse:: ).append(SessionServiceClient.externalKey( , Codec.STRING), (r, v) -> r.authorizationGrant = v, (r) -> r.authorizationGrant).add()).build();
}
}
{
String accessToken;
BuilderCodec<AccessTokenResponse> CODEC;
{
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(AccessTokenResponse.class, AccessTokenResponse:: ).append(SessionServiceClient.externalKey( , Codec.STRING), (r, v) -> r.accessToken = v, (r) -> r.accessToken).add()).build();
}
}
{
String sessionToken;
String identityToken;
String expiresAt;
BuilderCodec<GameSessionResponse> CODEC;
{
}
Instant {
( .expiresAt == ) {
;
} {
{
Instant.parse( .expiresAt);
} (Exception var2) {
;
}
}
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(GameSessionResponse.class, GameSessionResponse:: ).append(SessionServiceClient.externalKey( , Codec.STRING), (r, v) -> r.sessionToken = v, (r) -> r.sessionToken).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (r, v) -> r.identityToken = v, (r) -> r.identityToken).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (r, v) -> r.expiresAt = v, (r) -> r.expiresAt).add()).build();
}
}
{
JwkKey[] keys;
BuilderCodec<JwksResponse> CODEC;
{
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(JwksResponse.class, JwksResponse:: ).append(SessionServiceClient.externalKey( , (SessionServiceClient.JwkKey.CODEC, (x$ ) -> [x$ ])), (r, v) -> r.keys = v, (r) -> r.keys).add()).build();
}
}
{
String kty;
String alg;
String use;
String kid;
String crv;
String x;
String y;
String n;
String e;
BuilderCodec<JwkKey> CODEC;
{
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(JwkKey.class, JwkKey:: ).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.kty = v, (k) -> k.kty).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.alg = v, (k) -> k.alg).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.use = v, (k) -> k.use).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.kid = v, (k) -> k.kid).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.crv = v, (k) -> k.crv).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.x = v, (k) -> k.x).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.y = v, (k) -> k.y).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.n = v, (k) -> k.n).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (k, v) -> k.e = v, (k) -> k.e).add()).build();
}
}
{
UUID owner;
GameProfile[] profiles;
BuilderCodec<LauncherDataResponse> CODEC;
{
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(LauncherDataResponse.class, LauncherDataResponse:: ).append(SessionServiceClient.externalKey( , Codec.UUID_STRING), (r, v) -> r.owner = v, (r) -> r.owner).add()).append(SessionServiceClient.externalKey( , (SessionServiceClient.GameProfile.CODEC, (x$ ) -> [x$ ])), (r, v) -> r.profiles = v, (r) -> r.profiles).add()).build();
}
}
{
UUID uuid;
String username;
BuilderCodec<GameProfile> CODEC;
{
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(GameProfile.class, GameProfile:: ).append(SessionServiceClient.externalKey( , Codec.UUID_STRING), (p, v) -> p.uuid = v, (p) -> p.uuid).add()).append(SessionServiceClient.externalKey( , Codec.STRING), (p, v) -> p.username = v, (p) -> p.username).add()).build();
}
}
}
com/hypixel/hytale/server/core/auth/oauth/OAuthBrowserFlow.java
package com.hypixel.hytale.server.core.auth.oauth;
public abstract class OAuthBrowserFlow extends OAuthFlow {
public OAuthBrowserFlow () {
}
public abstract void onFlowInfo (String var1) ;
}
com/hypixel/hytale/server/core/auth/oauth/OAuthClient.java
package com.hypixel.hytale.server.core.auth.oauth;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.auth.AuthConfig;
import com.sun.net.httpserver.HttpServer;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.time.Duration;
import java.util.Base64;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class OAuthClient {
private static HytaleLogger.forEnclosingClass();
();
HttpClient.newBuilder().connectTimeout(Duration.ofSeconds( )).build();
{
}
Runnable {
( );
CompletableFuture.runAsync(() -> {
;
{
.generateRandomString( );
.generateRandomString( );
.generateCodeChallenge(codeVerifier);
server = HttpServer.create( ( , ), );
server.getAddress().getPort();
.encodeStateWithPort(csrfState, port);
;
CompletableFuture<String> authCodeFuture = ();
server.createContext( , (exchange) -> {
{
exchange.getRequestURI().getQuery();
.extractParam(query, );
.extractParam(query, );
String response;
statusCode;
(returnedEncodedState != && returnedEncodedState.equals(csrfState)) {
(code != && !code.isEmpty()) {
response = buildHtmlPage( , , , , (String) );
statusCode = ;
authCodeFuture.complete(code);
} {
.extractParam(query, );
error != ? error : ;
response = buildHtmlPage( , , , , errorMsg);
statusCode = ;
authCodeFuture.completeExceptionally( (errorMsg));
}
} {
response = buildHtmlPage( , , , , );
statusCode = ;
authCodeFuture.completeExceptionally( ( ));
}
exchange.sendResponseHeaders(statusCode, ( )response.length());
exchange.getResponseBody();
{
os.write(response.getBytes(StandardCharsets.UTF_8));
} (Throwable var19) {
(os != ) {
{
os.close();
} (Throwable x2) {
var19.addSuppressed(x2);
}
}
var19;
}
(os != ) {
os.close();
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
} {
HytaleServer.SCHEDULED_EXECUTOR.schedule(() -> server.stop( ), , TimeUnit.SECONDS);
}
});
server.setExecutor((Executor) );
server.start();
.buildAuthUrl(encodedState, codeChallenge, redirectUri);
flow.onFlowInfo(authUrl);
(String)authCodeFuture.get( , TimeUnit.MINUTES);
(!cancelled.get()) {
.exchangeCodeForTokens(authCode, codeVerifier, redirectUri);
(oauthTokens == ) {
flow.onFailure( );
;
}
flow.onSuccess(oauthTokens);
;
}
flow.onFailure( );
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
(!cancelled.get()) {
flow.onFailure(e.getMessage());
}
;
} {
(server != ) {
server.stop( );
}
}
});
() -> cancelled.set( );
}
Runnable {
( );
CompletableFuture.runAsync(() -> {
{
.requestDeviceAuthorization();
(deviceAuth == ) {
flow.onFailure( );
;
}
flow.onFlowInfo(deviceAuth.userCode(), deviceAuth.verificationUri(), deviceAuth.verificationUriComplete(), deviceAuth.expiresIn());
Math.max(deviceAuth.interval, );
System.currentTimeMillis() + ( )deviceAuth.expiresIn * ;
(System.currentTimeMillis() < deadline && !cancelled.get()) {
Thread.sleep(( )pollInterval * );
.pollDeviceToken(deviceAuth.deviceCode);
(tokens != ) {
(tokens.error == ) {
flow.onSuccess(tokens);
;
}
(! .equals(tokens.error)) {
(! .equals(tokens.error)) {
flow.onFailure( + tokens.error);
;
}
pollInterval += ;
}
}
}
(cancelled.get()) {
flow.onFailure( );
} {
flow.onFailure( );
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
(!cancelled.get()) {
flow.onFailure(e.getMessage());
}
}
});
() -> cancelled.set( );
}
TokenResponse {
{
URLEncoder.encode( , StandardCharsets.UTF_8);
+ var10000 + + URLEncoder.encode(refreshToken, StandardCharsets.UTF_8);
HttpRequest.newBuilder().uri(URI.create( )).header( , ).header( , AuthConfig.USER_AGENT).POST(BodyPublishers.ofString(body)).build();
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
.parseTokenResponse((String)response.body());
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
String {
URLEncoder.encode( , StandardCharsets.UTF_8);
+ var10000 + + URLEncoder.encode(redirectUri, StandardCharsets.UTF_8) + + URLEncoder.encode(String.join( , AuthConfig.SCOPES), StandardCharsets.UTF_8) + + URLEncoder.encode(state, StandardCharsets.UTF_8) + + URLEncoder.encode(codeChallenge, StandardCharsets.UTF_8) + ;
}
TokenResponse {
{
URLEncoder.encode( , StandardCharsets.UTF_8);
+ var10000 + + URLEncoder.encode(code, StandardCharsets.UTF_8) + + URLEncoder.encode(redirectUri, StandardCharsets.UTF_8) + + URLEncoder.encode(codeVerifier, StandardCharsets.UTF_8);
HttpRequest.newBuilder().uri(URI.create( )).header( , ).header( , AuthConfig.USER_AGENT).POST(BodyPublishers.ofString(body)).build();
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
.parseTokenResponse((String)response.body());
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
DeviceAuthResponse {
{
URLEncoder.encode( , StandardCharsets.UTF_8);
+ var10000 + + URLEncoder.encode(String.join( , AuthConfig.SCOPES), StandardCharsets.UTF_8);
HttpRequest.newBuilder().uri(URI.create( )).header( , ).header( , AuthConfig.USER_AGENT).POST(BodyPublishers.ofString(body)).build();
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
.parseDeviceAuthResponse((String)response.body());
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
TokenResponse {
{
URLEncoder.encode( , StandardCharsets.UTF_8);
+ var10000 + + URLEncoder.encode(deviceCode, StandardCharsets.UTF_8);
HttpRequest.newBuilder().uri(URI.create( )).header( , ).header( , AuthConfig.USER_AGENT).POST(BodyPublishers.ofString(body)).build();
HttpResponse<String> response = .httpClient.send(request, BodyHandlers.ofString());
(response.statusCode() == ) {
.parseTokenResponse((String)response.body());
} (response.statusCode() != ) {
LOGGER.at(Level.WARNING).log( , response.statusCode(), response.body());
;
} {
.parseTokenResponse((String)response.body());
}
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
String {
[] bytes = [length];
RANDOM.nextBytes(bytes);
Base64.getUrlEncoder().withoutPadding().encodeToString(bytes).substring( , length);
}
String {
{
MessageDigest.getInstance( );
[] hash = digest.digest(verifier.getBytes(StandardCharsets.US_ASCII));
Base64.getUrlEncoder().withoutPadding().encodeToString(hash);
} (Exception e) {
( , e);
}
}
String {
(query == ) {
;
} {
Pattern.compile(name + );
pattern.matcher(query);
matcher.find() ? URLDecoder.decode(matcher.group( ), StandardCharsets.UTF_8) : ;
}
}
String {
String.format( , state, port);
Base64.getUrlEncoder().withoutPadding().encodeToString(json.getBytes(StandardCharsets.UTF_8));
}
TokenResponse {
JsonParser.parseString(json).getAsJsonObject();
(getJsonString(obj, ), getJsonString(obj, ), getJsonString(obj, ), getJsonString(obj, ), getJsonInt(obj, , ));
}
DeviceAuthResponse {
JsonParser.parseString(json).getAsJsonObject();
(getJsonString(obj, ), getJsonString(obj, ), getJsonString(obj, ), getJsonString(obj, ), getJsonInt(obj, , ), getJsonInt(obj, , ));
}
String {
obj.get(key);
elem != && elem.isJsonPrimitive() ? elem.getAsString() : ;
}
{
obj.get(key);
elem != && elem.isJsonPrimitive() ? elem.getAsInt() : defaultValue;
}
String {
errorDetail != && !errorDetail.isEmpty() ? + errorDetail + : ;
success ? : ;
success ? : ;
.formatted(title, iconClass, iconSvg, heading, message, detail);
}
{
}
{
{
.error == && .accessToken != ;
}
}
}
com/hypixel/hytale/server/core/auth/oauth/OAuthDeviceFlow.java
package com.hypixel.hytale.server.core.auth.oauth;
public abstract class OAuthDeviceFlow extends OAuthFlow {
public OAuthDeviceFlow () {
}
public abstract void onFlowInfo (String var1, String var2, String var3, int var4) ;
}
com/hypixel/hytale/server/core/auth/oauth/OAuthFlow.java
package com.hypixel.hytale.server.core.auth.oauth;
import java.util.concurrent.CompletableFuture;
abstract class OAuthFlow {
private OAuthClient.TokenResponse tokenResponse = null ;
private final CompletableFuture<OAuthResult> future = new CompletableFuture ();
private OAuthResult result;
private String errorMessage;
OAuthFlow() {
this .result = OAuthResult.UNKNOWN;
this .errorMessage = null ;
}
final void onSuccess (OAuthClient.TokenResponse tokenResponse) {
if (!this .future.isDone()) {
this .tokenResponse = tokenResponse;
this .result = OAuthResult.SUCCESS;
this .future.complete(this .result);
}
}
final void onFailure (String errorMessage) {
if (!this .future.isDone()) {
this .errorMessage = errorMessage;
this .result = OAuthResult.FAILED;
}
}
public OAuthClient.TokenResponse getTokenResponse () {
return this .tokenResponse;
}
OAuthResult {
.result;
}
String {
.errorMessage;
}
CompletableFuture<OAuthResult> {
.future;
}
}
com/hypixel/hytale/server/core/auth/oauth/OAuthResult.java
package com.hypixel.hytale.server.core.auth.oauth;
public enum OAuthResult {
UNKNOWN,
SUCCESS,
FAILED;
private OAuthResult () {
}
}
com/hypixel/hytale/server/core/blocktype/BlockTypeModule.java
package com.hypixel.hytale.server.core.blocktype;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.DisableProcessingAssert;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.dependency.SystemDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.BenchType;
import com.hypixel.hytale.protocol.BlockMaterial;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.StateData;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Bench;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.CraftingBench;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.DiagramCraftingBench;
com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.ProcessingBench;
com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.StructuralCraftingBench;
com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
com.hypixel.hytale.server.core.modules.LegacyModule;
com.hypixel.hytale.server.core.modules.item.ItemModule;
com.hypixel.hytale.server.core.modules.migrations.ChunkColumnMigrationSystem;
com.hypixel.hytale.server.core.plugin.JavaPlugin;
com.hypixel.hytale.server.core.plugin.JavaPluginInit;
com.hypixel.hytale.server.core.universe.world.World;
com.hypixel.hytale.server.core.universe.world.accessor.BlockAccessor;
com.hypixel.hytale.server.core.universe.world.accessor.ChunkAccessor;
com.hypixel.hytale.server.core.universe.world.accessor.LocalCachedChunkAccessor;
com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
com.hypixel.hytale.server.core.universe.world.chunk.systems.ChunkSystems;
com.hypixel.hytale.server.core.universe.world.events.ChunkPreLoadProcessEvent;
com.hypixel.hytale.server.core.universe.world.meta.BlockState;
com.hypixel.hytale.server.core.universe.world.meta.BlockStateModule;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
java.util.Arrays;
java.util.Set;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
PluginManifest.corePlugin(BlockTypeModule.class).depends(ItemModule.class).depends(LegacyModule.class).build();
;
;
;
;
;
;
;
;
;
;
ThreadLocal<BlockType[]> TEMP_BLOCKS = ThreadLocal.withInitial(() -> [ ]);
BlockTypeModule instance;
ComponentType<ChunkStore, BlockPhysics> blockPhysicsComponentType;
BlockTypeModule {
instance;
}
{
(init);
instance = ;
}
{
Bench.CODEC.register(BenchType.Crafting, CraftingBench.class, CraftingBench.CODEC);
Bench.CODEC.register(BenchType.Processing, ProcessingBench.class, ProcessingBench.CODEC);
Bench.CODEC.register(BenchType.DiagramCrafting, DiagramCraftingBench.class, DiagramCraftingBench.CODEC);
Bench.CODEC.register(BenchType.StructuralCrafting, StructuralCraftingBench.class, StructuralCraftingBench.CODEC);
.blockPhysicsComponentType = .getChunkStoreRegistry().registerComponent(BlockPhysics.class, , BlockPhysics.CODEC);
.getChunkStoreRegistry().registerSystem( ());
}
ComponentType<ChunkStore, BlockPhysics> {
.blockPhysicsComponentType;
}
{
(event.isNewlyGenerated()) {
BlockTypeAssetMap<String, BlockType> blockTypeAssetMap = BlockType.getAssetMap();
Holder<ChunkStore> holder = event.getHolder();
event.getChunk();
(ChunkColumn)holder.getComponent(ChunkColumn.getComponentType());
(column != ) {
Holder<ChunkStore>[] sections = column.getSectionHolders();
(sections != ) {
( ; sectionIndex < ; ++sectionIndex) {
(BlockSection)sections[sectionIndex].ensureAndGetComponent(BlockSection.getComponentType());
(!section.isSolidAir()) {
sectionIndex << ;
( ; sectionY < ; ++sectionY) {
sectionYBlock | sectionY;
( ; x < ; ++x) {
( ; z < ; ++z) {
section.get(x, y, z);
blockTypeAssetMap.getAsset(blockId);
(blockType != && !blockType.isUnknown() && section.getFiller(x, y, z) == ) {
blockType.getState();
(state != && state.getId() != && chunk.getState(x, y, z) == ) {
(x, y, z);
BlockStateModule.get().createBlockState(state.getId(), chunk, position, blockType);
(blockState != ) {
chunk.setState(x, y, z, blockState);
}
}
}
}
}
}
}
}
}
}
}
}
{
(event.isNewlyGenerated()) {
event.getChunk();
chunk.getBlockChunk();
Holder<ChunkStore> holder = event.getHolder();
(ChunkColumn)holder.getComponent(ChunkColumn.getComponentType());
(column != ) {
Holder<ChunkStore>[] sections = column.getSectionHolders();
(sections != ) {
BlockType[] tempBlocks = (BlockType[])TEMP_BLOCKS.get();
Arrays.fill(tempBlocks, (Object) );
( ; sectionIndex < ; ++sectionIndex) {
(BlockSection)sections[sectionIndex].ensureAndGetComponent(BlockSection.getComponentType());
(!section.isSolidAir() && !(section.getMaximumHitboxExtent() <= )) {
onChunksectionPreLoadProcess(chunk, section, sectionIndex, tempBlocks);
}
}
}
}
}
}
{
sectionIndex << ;
BlockTypeAssetMap<String, BlockType> blockTypeAssetMap = BlockType.getAssetMap();
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> hitboxAssetMap = BlockBoundingBoxes.getAssetMap();
( ; y < ; ++y) {
sectionYBlock | y;
( ; x < ; ++x) {
x;
( ; z < ; ++z) {
getBlockType(blockTypeAssetMap, blocks, section, finalX, finalY, z, );
(blockType != ) {
section.getRotationIndex(x, y, z);
section.getFiller(x, y, z);
(filler != ) {
finalX - FillerBlockUtil.unpackX(filler);
(blockX >= && blockX < ) {
finalY - FillerBlockUtil.unpackY(filler);
(blockY >= && blockY < ) {
z - FillerBlockUtil.unpackZ(filler);
(blockZ >= && blockZ < ) {
getBlockType(blockTypeAssetMap, blocks, section, blockX, blockY, blockZ, );
(originBlockType != ) {
blockType.getId();
(blockType.isUnknown() || !blockTypeKey.equals(originBlockType.getId())) {
chunk.breakBlock(finalX, finalY, z, );
}
}
}
}
}
} {
blockTypeAssetMap.getIndex(blockType.getId());
FillerBlockUtil.forEachFillerBlock(((BlockBoundingBoxes)hitboxAssetMap.getAsset(blockType.getHitboxTypeIndex())).get(rotation), (x1, y1, z1) -> {
(x1 != || y1 != || z1 != ) {
finalX + x1;
(blockX >= && blockX < ) {
finalY + y1;
(blockY >= && blockY < ) {
z + z1;
(blockZ >= && blockZ < ) {
getBlockType(blockTypeAssetMap, blocks, section, blockX, blockY, blockZ, );
(neighbourBlockType != && neighbourBlockType.getMaterial() != BlockMaterial.Solid) {
FillerBlockUtil.pack(x1, y1, z1);
chunk.setBlock(blockX, blockY, blockZ, blockId, blockType, rotation, newFiller, );
}
}
}
}
}
});
}
}
}
}
}
}
BlockType {
ChunkUtil.indexBlockInColumn(blockX, blockY, blockZ);
blocks[indexBlock];
(blockType == ) {
section.get(blockX, blockY, blockZ);
(blockId == ) {
blocks[indexBlock] = BlockType.EMPTY;
skipEmpty ? : BlockType.EMPTY;
} {
blocks[indexBlock] = blockTypeAssetMap.getAsset(blockId);
}
} {
skipEmpty && .equals(blockType.getId()) ? : blockType;
}
}
{
chunk.getFiller(finalX, finalY, finalZ);
(filler != ) {
(!isFillerValid(blockTypeAssetMap, accessor, chunk, blockType, filler, finalX, finalY, finalZ)) {
chunk.breakBlock(finalX, finalY, finalZ, );
} {
finalX - FillerBlockUtil.unpackX(filler);
finalY - FillerBlockUtil.unpackY(filler);
finalZ - FillerBlockUtil.unpackZ(filler);
setFillerBlocks(blockTypeAssetMap, hitboxAssetMap, accessor, chunk, originX, originY, originZ, blockType, rotation);
}
} {
setFillerBlocks(blockTypeAssetMap, hitboxAssetMap, accessor, chunk, finalX, finalY, finalZ, blockType, rotation);
}
}
BlockType {
(originX >= && originX < && originY >= && originY < && originZ >= && originZ < ) {
section.getBlock(originX, originY, originZ);
blockTypeAssetMap.getAsset(originBlockId);
} {
(section.getX() << ) + originX;
(section.getZ() << ) + originZ;
accessor.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(worldX, worldZ));
(fillerOriginChunk != ) {
fillerOriginChunk.getBlock(originX, originY, originZ);
blockTypeAssetMap.getAsset(originBlockId);
} {
get().getLogger().at(Level.WARNING).log( , originX, originY, originZ);
fillerOriginChunk = accessor.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(worldX, worldZ));
fillerOriginChunk.getBlock(originX, originY, originZ);
blockTypeAssetMap.getAsset(originBlockId);
}
}
}
{
blockTypeAssetMap.getIndex(originBlockType.getId());
FillerBlockUtil.forEachFillerBlock(((BlockBoundingBoxes)hitboxAssetMap.getAsset(originBlockType.getHitboxTypeIndex())).get(rotation), (x1, y1, z1) -> {
(x1 != || y1 != || z1 != ) {
finalX + x1;
finalY + y1;
finalZ + z1;
(blockX >= && blockX < && blockY >= && blockY < && blockZ >= && blockZ < ) {
chunk.getBlock(blockX, blockY, blockZ);
chunk.getRotationIndex(blockX, blockY, blockZ);
chunk.getFiller(blockX, blockY, blockZ);
blockTypeAssetMap.getAsset(blockId);
((currentFiller == || !isFillerValid(blockTypeAssetMap, accessor, chunk, blockType, currentFiller, blockX, blockY, blockZ)) && blockType.getMaterial() != BlockMaterial.Solid) {
FillerBlockUtil.pack(x1, y1, z1);
chunk.setBlock(blockX, blockY, blockZ, originBlockId, originBlockType, currentRotation, filler, );
}
} {
(chunk.getX() << ) + blockX;
(chunk.getZ() << ) + blockZ;
accessor.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(worldX, worldZ));
(neighbourChunk != ) {
neighbourChunk.getBlock(blockX, blockY, blockZ);
neighbourChunk.getRotationIndex(blockX, blockY, blockZ);
neighbourChunk.getFiller(blockX, blockY, blockZ);
blockTypeAssetMap.getAsset(blockId);
((currentFiller == || !isFillerValid(blockTypeAssetMap, accessor, chunk, blockType, currentFiller, blockX, blockY, blockZ)) && blockType.getMaterial() != BlockMaterial.Solid) {
FillerBlockUtil.pack(x1, y1, z1);
neighbourChunk.setBlock(blockX, blockY, blockZ, originBlockId, originBlockType, currentRotation, filler, );
}
}
}
}
});
}
{
x - FillerBlockUtil.unpackX(filler);
y - FillerBlockUtil.unpackY(filler);
z - FillerBlockUtil.unpackZ(filler);
getOriginBlockType(blockTypeAssetMap, accessor, chunk, originX, originY, originZ);
(blockType.isUnknown()) {
;
} {
blockType.getId();
blockTypeKey.equals(originBlockType.getId());
}
}
<ChunkStore> {
ComponentType<ChunkStore, WorldChunk> COMPONENT_TYPE = WorldChunk.getComponentType();
{
}
Query<ChunkStore> {
COMPONENT_TYPE;
}
{
(WorldChunk)store.getComponent(ref, COMPONENT_TYPE);
(chunk.is(ChunkFlag.NEWLY_GENERATED)) {
((ChunkStore)store.getExternalData()).getWorld();
world.execute(() -> fixFillerFor(world, chunk));
}
}
{
chunk.getBlockChunk();
BlockTypeAssetMap<String, BlockType> blockTypeAssetMap = BlockType.getAssetMap();
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> hitboxAssetMap = BlockBoundingBoxes.getAssetMap();
LocalCachedChunkAccessor.atChunk(world, chunk, );
( - ; x < ; ++x) {
( - ; z < ; ++z) {
(x != || z != ) {
world.getChunkIfInMemory(ChunkUtil.indexChunk(x + chunk.getX(), z + chunk.getZ()));
(chunkIfInMemory != ) {
accessor.overwrite(chunkIfInMemory);
}
}
}
}
( ; sectionIndex < ; ++sectionIndex) {
blockChunk.getSectionAtIndex(sectionIndex);
section.getMaximumHitboxExtent() <= ;
sectionIndex << ;
( ; yInSection < ; ++yInSection) {
sectionYBlock | yInSection;
( - ; x < ; ++x) {
( - ; z < ; ++z) {
(x < || x >= || y < || y >= || z < || z >= ) {
(x >= && x < && y >= && y < && z >= && z < ) {
(!skipInsideSection) {
section.get(x, y, z);
(blockId != ) {
blockTypeAssetMap.getAsset(blockId);
section.getRotationIndex(x, y, z);
BlockTypeModule.breakOrSetFillerBlocks(blockTypeAssetMap, hitboxAssetMap, accessor, chunk, x, y, z, blockType, rotation);
}
}
} {
(chunk.getX() << ) + x;
(chunk.getZ() << ) + z;
accessor.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(worldX, worldZ));
(neighbourChunk != ) {
neighbourChunk.getBlockChunk().getSectionAtBlockY(y);
(!(neighbourSection.getMaximumHitboxExtent() <= )) {
neighbourSection.get(x, y, z);
(blockId != ) {
blockTypeAssetMap.getAsset(blockId);
neighbourSection.getRotationIndex(x, y, z);
BlockTypeModule.breakOrSetFillerBlocks(blockTypeAssetMap, hitboxAssetMap, accessor, chunk, x, y, z, blockType, rotation);
}
}
}
}
}
}
}
}
}
}
{
}
}
{
Query<ChunkStore> QUERY = Query.<ChunkStore>and(ChunkColumn.getComponentType(), BlockChunk.getComponentType());
Set<Dependency<ChunkStore>> DEPENDENCIES;
{
.DEPENDENCIES = Set.of( (Order.BEFORE, LegacyModule.MigrateLegacySections.class), (Order.AFTER, ChunkSystems.OnNewChunk.class), RootDependency.first());
}
{
(ChunkColumn)holder.getComponent(ChunkColumn.getComponentType());
column != ;
(BlockChunk)holder.getComponent(BlockChunk.getComponentType());
blockChunk != ;
Holder<ChunkStore>[] sections = column.getSectionHolders();
BlockSection[] legacySections = blockChunk.getMigratedSections();
(legacySections != ) {
( ; i < sections.length; ++i) {
Holder<ChunkStore> section = sections[i];
legacySections[i];
(section != && paletteSection != ) {
paletteSection.takeMigratedDecoBlocks();
(phys != ) {
section.putComponent(BlockPhysics.getComponentType(), phys);
blockChunk.markNeedsSaving();
}
}
}
}
}
{
}
Query<ChunkStore> {
.QUERY;
}
Set<Dependency<ChunkStore>> {
.DEPENDENCIES;
}
}
}
com/hypixel/hytale/server/core/blocktype/component/BlockPhysics.java
package com.hypixel.hytale.server.core.blocktype.component;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.util.BitUtil;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.blocktype.BlockTypeModule;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import java.util.Arrays;
import java.util.concurrent.locks.StampedLock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockPhysics implements Component <ChunkStore> {
public static final int VERSION = 0 ;
public BuilderCodec<BlockPhysics> CODEC;
;
;
;
();
[] supportData = ;
;
{
}
ComponentType<ChunkStore, BlockPhysics> {
BlockTypeModule.get().getBlockPhysicsComponentType();
}
{
.lock.writeLock();
{
support &= ;
( .supportData == ) {
(support == ) {
;
var11;
}
.supportData = [ ];
}
BitUtil.getAndSetNibble( .supportData, index, ( )support);
(previousValue == support) {
;
var12;
} {
(previousValue == ) {
++ .nonZeroCount;
} (support == ) {
-- .nonZeroCount;
( .nonZeroCount <= ) {
.supportData = ;
}
}
;
var6;
}
} {
.lock.unlockWrite(stamp);
}
}
{
.set(ChunkUtil.indexBlock(x, y, z), support);
}
{
.lock.readLock();
var4;
{
( .supportData != ) {
var4 = BitUtil.getNibble( .supportData, index);
var4;
}
var4 = ;
} {
.lock.unlockRead(stamp);
}
var4;
}
{
.get(ChunkUtil.indexBlock(x, y, z));
}
{
.isDeco(ChunkUtil.indexBlock(x, y, z));
}
{
.get(index) == ;
}
Component<ChunkStore> {
();
( .supportData != ) {
decoBlocks.supportData = Arrays.copyOf( .supportData, .supportData.length);
decoBlocks.nonZeroCount = .nonZeroCount;
}
decoBlocks;
}
[] serialize(ExtraInfo extraInfo) {
ByteBufAllocator.DEFAULT.buffer();
{
buf.writeBoolean( .supportData != );
( .supportData != ) {
buf.writeBytes( .supportData);
}
ByteBufUtil.getBytesRelease(buf);
} (Throwable e) {
buf.release();
SneakyThrow.sneakyThrow(e);
}
}
{
Unpooled.wrappedBuffer(bytes);
(buf.readBoolean()) {
.supportData = [ ];
buf.readBytes( .supportData);
.nonZeroCount = ;
( ; i < ; ++i) {
.supportData[i];
((v & ) != ) {
++ .nonZeroCount;
}
((v & ) != ) {
++ .nonZeroCount;
}
}
} {
.supportData = ;
.nonZeroCount = ;
}
}
{
(BlockPhysics)store.getComponent(section, getComponentType());
(blockPhysics != ) {
blockPhysics.set(ChunkUtil.indexBlock(x, y, z), );
}
}
{
(BlockPhysics)section.getComponent(getComponentType());
(blockPhysics != ) {
blockPhysics.set(ChunkUtil.indexBlock(x, y, z), );
}
}
{
(BlockPhysics)store.getComponent(section, getComponentType());
(blockPhysics == ) {
blockPhysics = (BlockPhysics)store.ensureAndGetComponent(section, getComponentType());
}
blockPhysics.set(ChunkUtil.indexBlock(x, y, z), );
}
{
setSupportValue(section, x, y, z, );
}
{
(BlockPhysics)store.getComponent(section, getComponentType());
(blockPhysics == ) {
blockPhysics = (BlockPhysics)store.ensureAndGetComponent(section, getComponentType());
}
blockPhysics.set(ChunkUtil.indexBlock(x, y, z), );
}
{
(BlockPhysics)store.getComponent(section, getComponentType());
(blockPhysics == ) {
blockPhysics = (BlockPhysics)store.ensureAndGetComponent(section, getComponentType());
}
blockPhysics.set(ChunkUtil.indexBlock(x, y, z), value);
}
{
(BlockPhysics)section.getComponent(getComponentType());
(blockPhysics == ) {
blockPhysics = (BlockPhysics)section.ensureAndGetComponent(getComponentType());
}
blockPhysics.set(ChunkUtil.indexBlock(x, y, z), value);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(BlockPhysics.class, BlockPhysics:: ).versioned()).codecVersion( )).append( ( , Codec.BYTE_ARRAY), BlockPhysics::deserialize, BlockPhysics::serialize).add()).build();
}
}
com/hypixel/hytale/server/core/client/ClientFeatureHandler.java
package com.hypixel.hytale.server.core.client;
import com.hypixel.hytale.protocol.packets.setup.ClientFeature;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
public class ClientFeatureHandler {
public ClientFeatureHandler () {
}
public static void register (@Nonnull ClientFeature feature) {
for (World world : Universe.get().getWorlds().values()) {
world.registerFeature(feature, true );
}
}
public static void unregister (@Nonnull ClientFeature feature) {
for (World world : Universe.get().getWorlds().values()) {
world.registerFeature(feature, false );
}
}
}
com/hypixel/hytale/server/core/codec/BoolDoublePairCodec.java
package com.hypixel.hytale.server.core.codec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.NumberSchema;
import com.hypixel.hytale.codec.schema.config.Schema;
import com.hypixel.hytale.codec.schema.config.StringSchema;
import com.hypixel.hytale.common.tuple.BoolDoublePair;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import org.bson.BsonString;
import org.bson.BsonValue;
public class BoolDoublePairCodec implements Codec <BoolDoublePair> {
private static final Pattern PATTERN = Pattern.compile("~?[0-9]*" );
public BoolDoublePairCodec () {
}
@Nonnull
public BoolDoublePair decode (BsonValue bsonValue, ExtraInfo extraInfo) {
if (bsonValue instanceof BsonString) {
String str = bsonValue.asString().getValue();
if (str.charAt(0 ) == '~' ) {
return str.length() == 1 ? BoolDoublePair.of(true , ) : BoolDoublePair.of( , Double.parseDouble(str.substring( )));
} {
BoolDoublePair.of( , Double.parseDouble(str));
}
} {
BoolDoublePair.of( , bsonValue.asDouble().getValue());
}
}
BsonValue {
pair.getLeft() ? : ;
(var10002 + pair.getRight());
}
Schema {
();
s.setPattern(PATTERN);
Schema.anyOf( (), s);
}
}
com/hypixel/hytale/server/core/codec/LayerEntryCodec.java
package com.hypixel.hytale.server.core.codec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.validation.Validators;
import javax.annotation.Nonnull;
public class LayerEntryCodec {
public static final BuilderCodec<LayerEntryCodec> CODEC;
private Integer depth;
private String material;
private boolean useToolArg = false ;
public LayerEntryCodec () {
}
public LayerEntryCodec (Integer depth, String material, boolean useToolArg) {
this .depth = depth;
this .material = material;
this .useToolArg = useToolArg;
}
@Nonnull
public Integer getDepth () {
return this .depth;
}
@Nonnull
public String getMaterial () {
return this .material;
}
public boolean isUseToolArg {
.useToolArg;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(LayerEntryCodec.class, LayerEntryCodec:: ).append( ( , Codec.INTEGER), (entry, depth) -> entry.depth = depth, (entry) -> entry.depth).addValidator(Validators.nonNull()).add()).append( ( , Codec.STRING), (entry, material) -> entry.material = material, (entry) -> entry.material).addValidator(Validators.nonNull()).add()).append( ( , Codec.BOOLEAN), (entry, useToolArg) -> entry.useToolArg = useToolArg != && useToolArg, (entry) -> entry.useToolArg).add()).build();
}
}
com/hypixel/hytale/server/core/codec/PairCodec.java
package com.hypixel.hytale.server.core.codec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.validation.Validators;
import it.unimi.dsi.fastutil.Pair;
import javax.annotation.Nonnull;
public class PairCodec {
public PairCodec () {
}
public static class IntegerPair {
public static final BuilderCodec<IntegerPair> CODEC;
private Integer left;
private Integer right;
public IntegerPair () {
}
public IntegerPair (Integer left, Integer right) {
this .left = left;
this .right = right;
}
@Nonnull
public Pair<Integer, Integer> toPair () {
return Pair.<Integer, Integer>of(this .left, this .right);
}
@Nonnull
public static IntegerPair fromPair (@Nonnull Pair<Integer, Integer> pair) {
(pair.left(), pair.right());
}
Integer {
.left;
}
Integer {
.right;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(IntegerPair.class, IntegerPair:: ).append( ( , Codec.INTEGER), (pair, left) -> pair.left = left, (pair) -> pair.left).addValidator(Validators.nonNull()).add()).append( ( , Codec.INTEGER), (pair, right) -> pair.right = right, (pair) -> pair.right).addValidator(Validators.nonNull()).add()).build();
}
}
{
BuilderCodec<IntegerStringPair> CODEC;
Integer left;
String right;
{
}
{
.left = left;
.right = right;
}
Pair<Integer, String> {
Pair.<Integer, String>of( .left, .right);
}
IntegerStringPair {
(pair.left(), pair.right());
}
Integer {
.left;
}
String {
.right;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(IntegerStringPair.class, IntegerStringPair:: ).append( ( , Codec.INTEGER), (pair, left) -> pair.left = left, (pair) -> pair.left).addValidator(Validators.nonNull()).add()).append( ( , Codec.STRING), (pair, right) -> pair.right = right, (pair) -> pair.right).addValidator(Validators.nonNull()).add()).build();
}
}
}
com/hypixel/hytale/server/core/codec/ProtocolCodecs.java
package com.hypixel.hytale.server.core.codec;
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.EnumCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.schema.metadata.HytaleType;
import com.hypixel.hytale.codec.schema.metadata.ui.UIDisplayMode;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.protocol.AccumulationMode;
import com.hypixel.hytale.protocol.ChangeStatBehaviour;
import com.hypixel.hytale.protocol.ChangeVelocityType;
import com.hypixel.hytale.protocol.Color;
import com.hypixel.hytale.protocol.ColorLight;
import com.hypixel.hytale.protocol.Direction;
import com.hypixel.hytale.protocol.EasingType;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.protocol.InitialVelocity;
import com.hypixel.hytale.protocol.IntersectionHighlight;
import com.hypixel.hytale.protocol.ItemAnimation;
import com.hypixel.hytale.protocol.RailConfig;
import com.hypixel.hytale.protocol.RailPoint;
import com.hypixel.hytale.protocol.Range;
import com.hypixel.hytale.protocol.RangeVector2f;
import com.hypixel.hytale.protocol.RangeVector3f;
import com.hypixel.hytale.protocol.Rangeb;
import com.hypixel.hytale.protocol.Rangef;
import com.hypixel.hytale.protocol.SavedMovementStates;
import com.hypixel.hytale.protocol.Size;
import com.hypixel.hytale.protocol.UVMotion;
com.hypixel.hytale.protocol.UVMotionCurveType;
com.hypixel.hytale.protocol.Vector2f;
com.hypixel.hytale.protocol.Vector3f;
com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
com.hypixel.hytale.server.core.asset.common.BlockyAnimationCache;
com.hypixel.hytale.server.core.asset.common.CommonAssetValidator;
com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
com.hypixel.hytale.server.core.codec.protocol.ColorAlphaCodec;
com.hypixel.hytale.server.core.codec.protocol.ColorCodec;
com.hypixel.hytale.server.core.util.PositionUtil;
{
BuilderCodec<Direction> DIRECTION;
BuilderCodec<Vector2f> VECTOR2F;
BuilderCodec<Vector3f> VECTOR3F;
BuilderCodec<ColorLight> COLOR_LIGHT;
ColorCodec COLOR;
ArrayCodec<Color> COLOR_ARRAY;
ColorAlphaCodec COLOR_AlPHA;
EnumCodec<GameMode> GAMEMODE;
EnumCodec<GameMode> GAMEMODE_LEGACY;
BuilderCodec<Size> SIZE;
BuilderCodec<Range> RANGE;
BuilderCodec<Rangeb> RANGEB;
BuilderCodec<Rangef> RANGEF;
BuilderCodec<RangeVector2f> RANGE_VECTOR2F;
BuilderCodec<RangeVector3f> RANGE_VECTOR3F;
BuilderCodec<InitialVelocity> INITIAL_VELOCITY;
BuilderCodec<UVMotion> UV_MOTION;
BuilderCodec<IntersectionHighlight> INTERSECTION_HIGHLIGHT;
BuilderCodec<SavedMovementStates> SAVED_MOVEMENT_STATES;
BuilderCodec<ContextMenuItem> CONTEXT_MENU_ITEM;
ArrayCodec<ContextMenuItem> CONTEXT_MENU_ITEM_ARRAY;
BuilderCodec<MapMarker> MARKER;
ArrayCodec<MapMarker> MARKER_ARRAY;
BuilderCodec<ItemAnimation> ITEM_ANIMATION_CODEC;
EnumCodec<ChangeStatBehaviour> CHANGE_STAT_BEHAVIOUR_CODEC;
EnumCodec<AccumulationMode> ACCUMULATION_MODE_CODEC;
EnumCodec<EasingType> EASING_TYPE_CODEC;
EnumCodec<ChangeVelocityType> CHANGE_VELOCITY_TYPE_CODEC;
BuilderCodec<RailPoint> RAIL_POINT_CODEC;
BuilderCodec<RailConfig> RAIL_CONFIG_CODEC;
{
}
{
DIRECTION = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Direction.class, Direction:: ).metadata(UIDisplayMode.COMPACT)).appendInherited( ( , Codec.FLOAT), (o, i) -> o.yaw = i, (o) -> o.yaw, (o, p) -> o.yaw = p.yaw).add()).appendInherited( ( , Codec.FLOAT), (o, i) -> o.pitch = i, (o) -> o.pitch, (o, p) -> o.pitch = p.pitch).add()).appendInherited( ( , Codec.FLOAT), (o, i) -> o.roll = i, (o) -> o.roll, (o, p) -> o.roll = p.roll).add()).build();
VECTOR2F = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Vector2f.class, Vector2f:: ).metadata(UIDisplayMode.COMPACT)).appendInherited( ( , Codec.FLOAT), (o, i) -> o.x = i, (o) -> o.x, (o, p) -> o.x = p.x).add()).appendInherited( ( , Codec.FLOAT), (o, i) -> o.y = i, (o) -> o.y, (o, p) -> o.y = p.y).add()).build();
VECTOR3F = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Vector3f.class, Vector3f:: ).metadata(UIDisplayMode.COMPACT)).appendInherited( ( , Codec.FLOAT), (o, i) -> o.x = i, (o) -> o.x, (o, p) -> o.x = p.x).add()).appendInherited( ( , Codec.FLOAT), (o, i) -> o.y = i, (o) -> o.y, (o, p) -> o.y = p.y).add()).appendInherited( ( , Codec.FLOAT), (o, i) -> o.z = i, (o) -> o.z, (o, p) -> o.z = p.z).add()).build();
COLOR_LIGHT = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ColorLight.class, ColorLight:: ).appendInherited( ( , Codec.STRING), ColorParseUtil::hexStringToColorLightDirect, ColorParseUtil::colorLightToHexString, (o, p) -> {
o.red = p.red;
o.green = p.green;
o.blue = p.blue;
}).metadata( ( )).add()).appendInherited( ( , Codec.BYTE), (o, i) -> o.radius = i, (o) -> o.radius, (o, p) -> o.radius = p.radius).add()).build();
COLOR = ();
COLOR_ARRAY = <Color>(COLOR, (x$ ) -> [x$ ]);
COLOR_AlPHA = ();
GAMEMODE = ( <GameMode>(GameMode.class)).documentKey(GameMode.Creative, ).documentKey(GameMode.Adventure, );
GAMEMODE_LEGACY = <GameMode>(GameMode.class, EnumCodec.EnumStyle.LEGACY);
SIZE = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Size.class, Size:: ).metadata(UIDisplayMode.COMPACT)).addField( ( , Codec.INTEGER), (size, i) -> size.width = i, (size) -> size.width)).addField( ( , Codec.INTEGER), (size, i) -> size.height = i, (size) -> size.height)).build();
RANGE = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Range.class, Range:: ).metadata(UIDisplayMode.COMPACT)).addField( ( , Codec.INTEGER), (rangeb, i) -> rangeb.min = i, (rangeb) -> rangeb.min)).addField( ( , Codec.INTEGER), (rangeb, i) -> rangeb.max = i, (rangeb) -> rangeb.max)).build();
RANGEB = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Rangeb.class, Rangeb:: ).metadata(UIDisplayMode.COMPACT)).addField( ( , Codec.BYTE), (rangeb, i) -> rangeb.min = i, (rangeb) -> rangeb.min)).addField( ( , Codec.BYTE), (rangeb, i) -> rangeb.max = i, (rangeb) -> rangeb.max)).build();
RANGEF = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Rangef.class, Rangef:: ).metadata(UIDisplayMode.COMPACT)).addField( ( , Codec.DOUBLE), (rangef, d) -> rangef.min = d.floatValue(), (rangeb) -> ( )rangeb.min)).addField( ( , Codec.DOUBLE), (rangef, d) -> rangef.max = d.floatValue(), (rangeb) -> ( )rangeb.max)).build();
RANGE_VECTOR2F = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(RangeVector2f.class, RangeVector2f:: ).addField( ( , RANGEF), (rangeVector2f, d) -> rangeVector2f.x = d, (rangeVector2f) -> rangeVector2f.x)).addField( ( , RANGEF), (rangeVector2f, d) -> rangeVector2f.y = d, (rangeVector2f) -> rangeVector2f.y)).build();
RANGE_VECTOR3F = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(RangeVector3f.class, RangeVector3f:: ).addField( ( , RANGEF), (rangeVector3f, d) -> rangeVector3f.x = d, (rangeVector3f) -> rangeVector3f.x)).addField( ( , RANGEF), (rangeVector3f, d) -> rangeVector3f.y = d, (rangeVector3f) -> rangeVector3f.y)).addField( ( , RANGEF), (rangeVector3f, d) -> rangeVector3f.z = d, (rangeVector3f) -> rangeVector3f.z)).build();
INITIAL_VELOCITY = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(InitialVelocity.class, InitialVelocity:: ).addField( ( , RANGEF), (rangeVector3f, d) -> rangeVector3f.yaw = d, (rangeVector3f) -> rangeVector3f.yaw)).addField( ( , RANGEF), (rangeVector3f, d) -> rangeVector3f.pitch = d, (rangeVector3f) -> rangeVector3f.pitch)).addField( ( , RANGEF), (rangeVector3f, d) -> rangeVector3f.speed = d, (rangeVector3f) -> rangeVector3f.speed)).build();
UV_MOTION = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(UVMotion.class, UVMotion:: ).append( ( , Codec.STRING), (uvMotion, s) -> uvMotion.texture = s, (uvMotion) -> uvMotion.texture).addValidator(CommonAssetValidator.TEXTURE_PARTICLES).add()).append( ( , Codec.BOOLEAN), (uvMotion, b) -> uvMotion.addRandomUVOffset = b, (uvMotion) -> uvMotion.addRandomUVOffset).add()).append( ( , Codec.DOUBLE), (uvMotion, s) -> uvMotion.speedX = s.floatValue(), (uvMotion) -> ( )uvMotion.speedX).addValidator(Validators.range(- , )).add()).append( ( , Codec.DOUBLE), (uvMotion, s) -> uvMotion.speedY = s.floatValue(), (uvMotion) -> ( )uvMotion.speedY).addValidator(Validators.range(- , )).add()).append( ( , Codec.DOUBLE), (uvMotion, s) -> uvMotion.strength = s.floatValue(), (uvMotion) -> ( )uvMotion.strength).addValidator(Validators.range( , )).add()).append( ( , (UVMotionCurveType.class)), (uvMotion, s) -> uvMotion.strengthCurveType = s, (uvMotion) -> uvMotion.strengthCurveType).add()).append( ( , Codec.DOUBLE), (uvMotion, s) -> uvMotion.scale = s.floatValue(), (uvMotion) -> ( )uvMotion.scale).addValidator(Validators.range( , )).add()).build();
INTERSECTION_HIGHLIGHT = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(IntersectionHighlight.class, IntersectionHighlight:: ).append( ( , Codec.FLOAT), (intersectionHighlight, s) -> intersectionHighlight.highlightThreshold = s, (intersectionHighlight) -> intersectionHighlight.highlightThreshold).addValidator(Validators.range( , )).add()).addField( ( , COLOR), (intersectionHighlight, s) -> intersectionHighlight.highlightColor = s, (intersectionHighlight) -> intersectionHighlight.highlightColor)).build();
SAVED_MOVEMENT_STATES = ((BuilderCodec.Builder)BuilderCodec.builder(SavedMovementStates.class, SavedMovementStates:: ).addField( ( , Codec.BOOLEAN), (movementStates, flying) -> movementStates.flying = flying, (movementStates) -> movementStates.flying)).build();
CONTEXT_MENU_ITEM = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ContextMenuItem.class, ContextMenuItem:: ).addField( ( , Codec.STRING), (item, s) -> item.name = s, (item) -> item.name)).addField( ( , Codec.STRING), (item, s) -> item.command = s, (item) -> item.command)).build();
CONTEXT_MENU_ITEM_ARRAY = <ContextMenuItem>(CONTEXT_MENU_ITEM, (x$ ) -> [x$ ]);
MARKER = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(MapMarker.class, MapMarker:: ).addField( ( , Codec.STRING), (marker, s) -> marker.id = s, (marker) -> marker.id)).addField( ( , Codec.STRING), (marker, s) -> marker.name = s, (marker) -> marker.name)).addField( ( , Codec.STRING), (marker, s) -> marker.markerImage = s, (marker) -> marker.markerImage)).append( ( , Transform.CODEC), (marker, s) -> marker.transform = PositionUtil.toTransformPacket(s), (marker) -> PositionUtil.toTransform(marker.transform)).addValidator(Validators.nonNull()).add()).addField( ( , CONTEXT_MENU_ITEM_ARRAY), (marker, items) -> marker.contextMenuItems = items, (marker) -> marker.contextMenuItems)).build();
MARKER_ARRAY = <MapMarker>(MARKER, (x$ ) -> [x$ ]);
ITEM_ANIMATION_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(ItemAnimation.class, ItemAnimation:: ).append( ( , Codec.STRING), (itemAnimation, s) -> itemAnimation.thirdPerson = s, (itemAnimation) -> itemAnimation.thirdPerson).addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER).add()).append( ( , Codec.STRING), (itemAnimation, s) -> itemAnimation.thirdPersonMoving = s, (itemAnimation) -> itemAnimation.thirdPersonMoving).addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER).add()).append( ( , Codec.STRING), (itemAnimation, s) -> itemAnimation.thirdPersonFace = s, (itemAnimation) -> itemAnimation.thirdPersonFace).addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER).add()).append( ( , Codec.STRING), (itemAnimation, s) -> itemAnimation.firstPerson = s, (itemAnimation) -> itemAnimation.firstPerson).addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER).add()).append( ( , Codec.STRING), (itemAnimation, s) -> itemAnimation.firstPersonOverride = s, (itemAnimation) -> itemAnimation.firstPersonOverride).addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER).add()).addField( ( , Codec.BOOLEAN), (itemAnimation, s) -> itemAnimation.keepPreviousFirstPersonAnimation = s, (itemAnimation) -> itemAnimation.keepPreviousFirstPersonAnimation)).addField( ( , Codec.DOUBLE), (itemAnimation, s) -> itemAnimation.speed = s.floatValue(), (itemAnimation) -> ( )itemAnimation.speed)).addField( ( , Codec.DOUBLE), (itemAnimation, s) -> itemAnimation.blendingDuration = s.floatValue(), (itemAnimation) -> ( )itemAnimation.blendingDuration)).addField( ( , Codec.BOOLEAN), (itemAnimation, s) -> itemAnimation.looping = s, (itemAnimation) -> itemAnimation.looping)).addField( ( , Codec.BOOLEAN), (itemAnimation, s) -> itemAnimation.clipsGeometry = s, (itemAnimation) -> itemAnimation.clipsGeometry)).afterDecode((itemAnimation) -> {
(itemAnimation.firstPerson != ) {
BlockyAnimationCache.get(itemAnimation.firstPerson);
}
(itemAnimation.firstPersonOverride != ) {
BlockyAnimationCache.get(itemAnimation.firstPersonOverride);
}
})).build();
CHANGE_STAT_BEHAVIOUR_CODEC = ( <ChangeStatBehaviour>(ChangeStatBehaviour.class)).documentKey(ChangeStatBehaviour.Add, ).documentKey(ChangeStatBehaviour.Set, );
ACCUMULATION_MODE_CODEC = ( <AccumulationMode>(AccumulationMode.class)).documentKey(AccumulationMode.Set, ).documentKey(AccumulationMode.Sum, ).documentKey(AccumulationMode.Average, );
EASING_TYPE_CODEC = <EasingType>(EasingType.class);
CHANGE_VELOCITY_TYPE_CODEC = ( <ChangeVelocityType>(ChangeVelocityType.class)).documentKey(ChangeVelocityType.Add, ).documentKey(ChangeVelocityType.Set, );
RAIL_POINT_CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(RailPoint.class, RailPoint:: ).appendInherited( ( , VECTOR3F), (o, v) -> o.point = v, (o) -> o.point, (o, p) -> o.point = p.point).addValidator(Validators.nonNull()).add()).appendInherited( ( , VECTOR3F), (o, v) -> o.normal = v, (o) -> o.normal, (o, p) -> o.normal = p.normal).addValidator(Validators.nonNull()).add()).afterDecode((o) -> {
(o.normal != ) {
com.hypixel.hytale.math.vector. .hypixel.hytale.math.vector.Vector3f(o.normal.x, o.normal.y, o.normal.z);
v = v.normalize();
o.normal.x = v.x;
o.normal.y = v.y;
o.normal.z = v.z;
}
})).build();
RAIL_CONFIG_CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(RailConfig.class, RailConfig:: ).appendInherited( ( , (RAIL_POINT_CODEC, (x$ ) -> [x$ ])), (o, v) -> o.points = v, (o) -> o.points, (o, p) -> o.points = p.points).addValidator(Validators.nonNull()).addValidator(Validators.arraySizeRange( , )).add()).build();
}
}
com/hypixel/hytale/server/core/codec/ShapeCodecs.java
package com.hypixel.hytale.server.core.codec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.lookup.CodecMapCodec;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.math.shape.Cylinder;
import com.hypixel.hytale.math.shape.Ellipsoid;
import com.hypixel.hytale.math.shape.OriginShape;
import com.hypixel.hytale.math.shape.Shape;
import com.hypixel.hytale.math.vector.Vector3d;
public class ShapeCodecs {
public static final CodecMapCodec<Shape> SHAPE = new CodecMapCodec <Shape>();
public static final BuilderCodec<Box> BOX;
public static final BuilderCodec<Ellipsoid> ELLIPSOID;
public static final BuilderCodec<Cylinder> CYLINDER;
public static final BuilderCodec<OriginShape<Shape>> ORIGIN_SHAPE;
public ShapeCodecs () {
}
static {
BOX = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Box.class, Box::new ).addField(new KeyedCodec ("Min" , Vector3d.CODEC), (shape, min) -> shape.min.assign(min), (shape) -> shape.min)).addField( ( , Vector3d.CODEC), (shape, max) -> shape.max.assign(max), (shape) -> shape.max)).build();
ELLIPSOID = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Ellipsoid.class, Ellipsoid:: ).addField( ( , Codec.DOUBLE), (shape, radius) -> shape.radiusX = radius, (shape) -> shape.radiusX)).addField( ( , Codec.DOUBLE), (shape, radius) -> shape.radiusY = radius, (shape) -> shape.radiusY)).addField( ( , Codec.DOUBLE), (shape, radius) -> shape.radiusZ = radius, (shape) -> shape.radiusZ)).addField( ( , Codec.DOUBLE), Ellipsoid::assign, (shape) -> )).build();
CYLINDER = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Cylinder.class, Cylinder:: ).addField( ( , Codec.DOUBLE), (shape, height) -> shape.height = height, (shape) -> shape.height)).addField( ( , Codec.DOUBLE), (shape, radiusX) -> shape.radiusX = radiusX, (shape) -> shape.radiusX)).addField( ( , Codec.DOUBLE), (shape, radiusZ) -> shape.radiusZ = radiusZ, (shape) -> shape.radiusZ)).addField( ( , Codec.DOUBLE), Cylinder::assign, (shape) -> )).build();
ORIGIN_SHAPE = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(OriginShape.class, OriginShape:: ).addField( ( , Vector3d.CODEC), (shape, origin) -> shape.origin.assign(origin), (shape) -> shape.origin)).addField( ( , SHAPE), (shape, childShape) -> shape.shape = (S)childShape, (shape) -> shape.shape)).build();
SHAPE.register((String) , Box.class, BOX);
SHAPE.register((String) , Ellipsoid.class, ELLIPSOID);
SHAPE.register((String) , Cylinder.class, CYLINDER);
SHAPE.register((String) , OriginShape.class, ORIGIN_SHAPE);
}
}
com/hypixel/hytale/server/core/codec/WeightedMapCodec.java
package com.hypixel.hytale.server.core.codec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.WrappedCodec;
import com.hypixel.hytale.codec.exception.CodecException;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.ArraySchema;
import com.hypixel.hytale.codec.schema.config.Schema;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.common.map.IWeightedElement;
import com.hypixel.hytale.common.map.IWeightedMap;
import com.hypixel.hytale.common.map.WeightedMap;
import java.io.IOException;
import javax.annotation.Nonnull;
import org.bson.BsonArray;
import org.bson.BsonValue;
public class WeightedMapCodec <T extends IWeightedElement > implements Codec <IWeightedMap<T>>, WrappedCodec<T> {
private final Codec<T> codec;
private final T[] emptyKeys;
public WeightedMapCodec (Codec<T> codec, T[] emptyKeys) {
this .codec = codec;
this .emptyKeys = emptyKeys;
}
public Codec<T> getChildCodec () {
return this .codec;
}
public IWeightedMap<T> decode {
bsonValue.asArray();
WeightedMap.Builder<T> mapBuilder = WeightedMap.<T>builder( .emptyKeys);
mapBuilder.ensureCapacity(array.size());
( ; i < array.size(); ++i) {
array.get(i);
extraInfo.pushIntKey(i);
{
.codec.decode(value, extraInfo);
mapBuilder.put(element, element.getWeight());
} (Exception e) {
( , value, extraInfo, e);
} {
extraInfo.popKey();
}
}
mapBuilder.build();
}
BsonValue {
();
map.forEach((element) -> array.add( .codec.encode(element, extraInfo)));
array;
}
IWeightedMap<T> IOException {
reader.expect( );
reader.consumeWhiteSpace();
WeightedMap.Builder<T> mapBuilder = WeightedMap.<T>builder( .emptyKeys);
(reader.tryConsume( )) {
mapBuilder.build();
} {
;
( ) {
extraInfo.pushIntKey(i, reader);
{
.codec.decodeJson(reader, extraInfo);
mapBuilder.put(element, element.getWeight());
} (Exception e) {
( , reader, extraInfo, e);
} {
extraInfo.popKey();
}
reader.consumeWhiteSpace();
(reader.tryConsumeOrExpect( , )) {
mapBuilder.build();
}
reader.consumeWhiteSpace();
}
}
}
Schema {
();
s.setTitle( );
s.setItem(context.refDefinition( .codec));
s;
}
}
com/hypixel/hytale/server/core/codec/protocol/ColorAlphaCodec.java
package com.hypixel.hytale.server.core.codec.protocol;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.exception.CodecException;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.Schema;
import com.hypixel.hytale.codec.schema.config.StringSchema;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.protocol.ColorAlpha;
import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
import java.io.IOException;
import javax.annotation.Nonnull;
import org.bson.BsonString;
import org.bson.BsonValue;
public class ColorAlphaCodec implements Codec <ColorAlpha> {
public ColorAlphaCodec () {
}
@Nonnull
public BsonValue encode (ColorAlpha colorAlpha, ExtraInfo extraInfo) {
return new BsonString (ColorParseUtil.colorToHexAlphaString(colorAlpha));
}
@Nonnull
public ColorAlpha decode (@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) {
ColorAlpha colorAlpha = ColorParseUtil.parseColorAlpha(bsonValue.asString().getValue());
if (colorAlpha != null ) {
colorAlpha;
} {
( );
}
}
ColorAlpha IOException {
reader.expect( );
ColorParseUtil.readColorAlpha(reader);
reader.expect( );
(colorAlpha != ) {
colorAlpha;
} {
( );
}
}
Schema {
();
hex.setPattern(ColorParseUtil.HEX_COLOR_PATTERN);
();
hexAlpha.setPattern(ColorParseUtil.HEX_ALPHA_COLOR_PATTERN);
();
rgbaHex.setPattern(ColorParseUtil.RGBA_HEX_COLOR_PATTERN);
();
rgba.setPattern(ColorParseUtil.RGBA_COLOR_PATTERN);
Schema.anyOf(hex, hexAlpha, rgbaHex, rgba);
s.setTitle( );
s.getHytale().setType( );
s;
}
}
com/hypixel/hytale/server/core/codec/protocol/ColorCodec.java
package com.hypixel.hytale.server.core.codec.protocol;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.exception.CodecException;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.Schema;
import com.hypixel.hytale.codec.schema.config.StringSchema;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.protocol.Color;
import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
import java.io.IOException;
import javax.annotation.Nonnull;
import org.bson.BsonString;
import org.bson.BsonValue;
public class ColorCodec implements Codec <Color> {
public ColorCodec () {
}
@Nonnull
public BsonValue encode (Color color, ExtraInfo extraInfo) {
return new BsonString (ColorParseUtil.colorToHexString(color));
}
@Nonnull
public Color decode (@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) {
Color color = ColorParseUtil.parseColor(bsonValue.asString().getValue());
if (color != null ) {
return color;
} {
( );
}
}
Color IOException {
reader.expect( );
ColorParseUtil.readColor(reader);
reader.expect( );
(color != ) {
color;
} {
( );
}
}
Schema {
();
hex.setPattern(ColorParseUtil.HEX_COLOR_PATTERN);
();
rgb.setPattern(ColorParseUtil.RGB_COLOR_PATTERN);
Schema.anyOf(hex, rgb);
s.setTitle( );
s.getHytale().setType( );
s;
}
}
com/hypixel/hytale/server/core/console/ConsoleModule.java
package com.hypixel.hytale.server.core.console;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.logger.backend.HytaleConsole;
import com.hypixel.hytale.server.core.Constants;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.ShutdownReason;
import com.hypixel.hytale.server.core.command.system.CommandManager;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.console.command.SayCommand;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import java.io.IOError;
import java.io.IOException;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
public class ConsoleModule extends JavaPlugin {
public static final PluginManifest MANIFEST = PluginManifest.corePlugin(ConsoleModule.class).build();
private static ConsoleModule instance;
private Terminal terminal;
ConsoleRunnable consoleRunnable;
ConsoleModule {
instance;
}
{
(init);
}
{
instance = ;
.getCommandRegistry().registerCommand( ());
{
TerminalBuilder.builder();
(Constants.SINGLEPLAYER) {
builder.dumb( );
} {
builder.color( );
}
.terminal = builder.build();
HytaleConsole.INSTANCE.setTerminal( .terminal.getType());
LineReaderBuilder.builder().terminal( .terminal).build();
.consoleRunnable = (lineReader, ConsoleSender.INSTANCE);
.getLogger().at(Level.INFO).log( , .terminal.getType());
} (IOException e) {
((HytaleLogger.Api) .getLogger().at(Level.SEVERE).withCause(e)).log( );
}
}
{
.getLogger().at(Level.INFO).log( );
{
.terminal.close();
} (IOException e) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(e)).log( );
}
.consoleRunnable.interrupt();
}
Terminal {
.terminal;
}
{
LineReader lineReader;
ConsoleSender consoleSender;
Thread consoleThread;
{
.lineReader = lineReader;
.consoleSender = consoleSender;
.consoleThread = ( , );
.consoleThread.setDaemon( );
.consoleThread.start();
}
{
{
.lineReader.getTerminal().getType();
String command;
( .equals(terminalType) || .equals(terminalType); ! .consoleThread.isInterrupted(); CommandManager.get().handleCommand((CommandSender) .consoleSender, command)) {
command = .lineReader.readLine(isDumb ? : );
(command == ) {
;
}
command = command.trim();
(!command.isEmpty() && command.charAt( ) == ) {
command = command.substring( );
}
}
} (UserInterruptException var4) {
HytaleServer.get().shutdownServer(ShutdownReason.SIGINT);
} (IOError | EndOfFileException var5) {
}
}
{
.consoleThread.interrupt();
}
}
}
com/hypixel/hytale/server/core/console/ConsoleSender.java
package com.hypixel.hytale.server.core.console;
import com.hypixel.hytale.logger.backend.HytaleLoggerBackend;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.util.MessageUtil;
import java.util.UUID;
import javax.annotation.Nonnull;
import org.jline.terminal.Terminal;
import org.jline.utils.AttributedString;
public class ConsoleSender implements CommandSender {
public static final ConsoleSender INSTANCE = new ConsoleSender ();
private final UUID uuid = new UUID (0L , 0L );
protected ConsoleSender () {
}
public void sendMessage (@Nonnull Message message) {
Terminal terminal = ConsoleModule.get().getTerminal();
AttributedString attributedString = MessageUtil.toAnsiString(message);
HytaleLoggerBackend.rawLog(attributedString.toAnsi(terminal));
}
String {
;
}
UUID {
.uuid;
}
{
;
}
{
;
}
}
com/hypixel/hytale/server/core/console/command/SayCommand.java
package com.hypixel.hytale.server.core.console.command;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandUtil;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.console.ConsoleSender;
import com.hypixel.hytale.server.core.universe.Universe;
import java.awt.Color;
import javax.annotation.Nonnull;
public class SayCommand extends CommandBase {
@Nonnull
private static final Color SAY_COMMAND_COLOR;
public SayCommand () {
super ("say" , "server.commands.say.desc" );
this .addAliases(new String []{"broadcast" });
this .setAllowsExtraArguments(true );
}
protected void executeSync (@Nonnull CommandContext context) {
String rawArgs = CommandUtil.stripCommandName(context.getInputString()).trim();
if (rawArgs.isEmpty()) {
context.sendMessage(Message.translation("server.commands.parsing.error.wrongNumberRequiredParameters" ).param( , ).param( , ));
} {
Message result;
(rawArgs.charAt( ) == ) {
{
result = Message.parse(rawArgs).color(SAY_COMMAND_COLOR);
} (IllegalArgumentException e) {
context.sendMessage(Message.raw( + e.getMessage()));
;
}
} {
result = Message.translation( ).param( , context.sender().getDisplayName()).param( , rawArgs).color(SAY_COMMAND_COLOR);
}
Universe.get().getWorlds().values().forEach((world) -> world.getPlayerRefs().forEach((playerRef) -> playerRef.sendMessage(result)));
ConsoleSender.INSTANCE.sendMessage(result);
}
}
{
SAY_COMMAND_COLOR = Color.CYAN;
}
}
com/hypixel/hytale/server/core/cosmetics/BodyType.java
package com.hypixel.hytale.server.core.cosmetics;
public enum BodyType {
Masculine,
Feminine;
private BodyType () {
}
}
com/hypixel/hytale/server/core/cosmetics/CosmeticAssetValidator.java
package com.hypixel.hytale.server.core.cosmetics;
import com.hypixel.hytale.codec.codecs.EnumCodec;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.Schema;
import com.hypixel.hytale.codec.schema.config.StringSchema;
import com.hypixel.hytale.codec.validation.ValidationResults;
import com.hypixel.hytale.codec.validation.Validator;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class CosmeticAssetValidator implements Validator <String> {
private final CosmeticType type;
public CosmeticAssetValidator (CosmeticType type) {
this .type = type;
}
public void accept (@Nullable String asset, @Nonnull ValidationResults results) {
if (asset != null ) {
CosmeticRegistry reg = CosmeticsModule.get().getRegistry();
Map<String, ?> toCheck = reg.getByType(this .type);
if (!toCheck.containsKey(asset)) {
String var10001 = String.valueOf(this .type);
results.fail("Cosmetic Asset (" + var10001 + ") '" + asset + );
}
}
}
{
((StringSchema)target).setHytaleCosmeticAsset(EnumCodec.EnumStyle.LEGACY.formatCamelCase( .type.name()));
}
}
com/hypixel/hytale/server/core/cosmetics/CosmeticRegistry.java
package com.hypixel.hytale.server.core.cosmetics;
import com.hypixel.hytale.assetstore.AssetPack;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nonnull;
import org.bson.BsonArray;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public class CosmeticRegistry {
public static final String MODEL = "Characters/Player.blockymodel" ;
public static final String SKIN_GRADIENTSET_ID = "Skin" ;
@Nonnull
private final Map<String, Emote> emotes;
@Nonnull
private final Map<String, PlayerSkinTintColor> eyeColors;
@Nonnull
private final Map<String, PlayerSkinGradientSet> gradientSets;
@Nonnull
private final Map<String, PlayerSkinPart> bodyCharacteristics;
@Nonnull
private Map<String, PlayerSkinPart> underwear;
Map<String, PlayerSkinPart> eyebrows;
Map<String, PlayerSkinPart> ears;
Map<String, PlayerSkinPart> eyes;
Map<String, PlayerSkinPart> faces;
Map<String, PlayerSkinPart> mouths;
Map<String, PlayerSkinPart> facialHair;
Map<String, PlayerSkinPart> pants;
Map<String, PlayerSkinPart> overpants;
Map<String, PlayerSkinPart> undertops;
Map<String, PlayerSkinPart> overtops;
Map<String, PlayerSkinPart> haircuts;
Map<String, PlayerSkinPart> shoes;
Map<String, PlayerSkinPart> headAccessory;
Map<String, PlayerSkinPart> faceAccessory;
Map<String, PlayerSkinPart> earAccessory;
Map<String, PlayerSkinPart> gloves;
Map<String, PlayerSkinPart> capes;
Map<String, PlayerSkinPart> skinFeatures;
{
pack.getRoot();
.emotes = .load(assetsDirectory, , Emote:: );
.eyeColors = .load(assetsDirectory, , PlayerSkinTintColor:: );
.gradientSets = .load(assetsDirectory, , PlayerSkinGradientSet:: );
.bodyCharacteristics = .load(assetsDirectory, , PlayerSkinPart:: );
.underwear = .load(assetsDirectory, , PlayerSkinPart:: );
.eyes = .load(assetsDirectory, , PlayerSkinPart:: );
.faces = .load(assetsDirectory, , PlayerSkinPart:: );
.eyebrows = .load(assetsDirectory, , PlayerSkinPart:: );
.ears = .load(assetsDirectory, , PlayerSkinPart:: );
.mouths = .load(assetsDirectory, , PlayerSkinPart:: );
.facialHair = .load(assetsDirectory, , PlayerSkinPart:: );
.pants = .load(assetsDirectory, , PlayerSkinPart:: );
.overpants = .load(assetsDirectory, , PlayerSkinPart:: );
.undertops = .load(assetsDirectory, , PlayerSkinPart:: );
.overtops = .load(assetsDirectory, , PlayerSkinPart:: );
.haircuts = .load(assetsDirectory, , PlayerSkinPart:: );
.shoes = .load(assetsDirectory, , PlayerSkinPart:: );
.headAccessory = .load(assetsDirectory, , PlayerSkinPart:: );
.faceAccessory = .load(assetsDirectory, , PlayerSkinPart:: );
.earAccessory = .load(assetsDirectory, , PlayerSkinPart:: );
.gloves = .load(assetsDirectory, , PlayerSkinPart:: );
.capes = .load(assetsDirectory, , PlayerSkinPart:: );
.skinFeatures = .load(assetsDirectory, , PlayerSkinPart:: );
}
<T> Map<String, T> {
Map<String, T> map = <String, T>();
assetsDirectory.resolve( ).resolve( ).resolve(file);
{
(BsonValue bsonValue : BsonArray.parse(Files.readString(path))) {
bsonValue.asDocument();
map.put(doc.getString( ).getValue(), func.apply(doc));
}
} (IOException e) {
e.printStackTrace();
}
Collections.unmodifiableMap(map);
}
Map<String, Emote> {
.emotes;
}
Map<String, PlayerSkinTintColor> {
.eyeColors;
}
Map<String, PlayerSkinGradientSet> {
.gradientSets;
}
Map<String, PlayerSkinPart> {
.bodyCharacteristics;
}
Map<String, PlayerSkinPart> {
.underwear;
}
Map<String, PlayerSkinPart> {
.eyebrows;
}
Map<String, PlayerSkinPart> {
.ears;
}
Map<String, PlayerSkinPart> {
.eyes;
}
Map<String, PlayerSkinPart> {
.faces;
}
Map<String, PlayerSkinPart> {
.mouths;
}
Map<String, PlayerSkinPart> {
.facialHair;
}
Map<String, PlayerSkinPart> {
.pants;
}
Map<String, PlayerSkinPart> {
.overpants;
}
Map<String, PlayerSkinPart> {
.undertops;
}
Map<String, PlayerSkinPart> {
.overtops;
}
Map<String, PlayerSkinPart> {
.haircuts;
}
Map<String, PlayerSkinPart> {
.shoes;
}
Map<String, PlayerSkinPart> {
.headAccessory;
}
Map<String, PlayerSkinPart> {
.faceAccessory;
}
Map<String, PlayerSkinPart> {
.earAccessory;
}
Map<String, PlayerSkinPart> {
.gloves;
}
Map<String, PlayerSkinPart> {
.skinFeatures;
}
Map<String, PlayerSkinPart> {
.capes;
}
Map<String, ?> getByType( CosmeticType type) {
Map var10000;
(type) {
EMOTES -> var10000 = .getEmotes();
SKIN_TONES -> var10000 = ((PlayerSkinGradientSet) .getGradientSets().get( )).getGradients();
EYE_COLORS -> var10000 = .getEyeColors();
GRADIENT_SETS -> var10000 = .getGradientSets();
BODY_CHARACTERISTICS -> var10000 = .getBodyCharacteristics();
UNDERWEAR -> var10000 = .getUnderwear();
EYEBROWS -> var10000 = .getEyebrows();
EARS -> var10000 = .getEars();
EYES -> var10000 = .getEyes();
FACE -> var10000 = .getFaces();
MOUTHS -> var10000 = .getMouths();
FACIAL_HAIR -> var10000 = .getFacialHairs();
PANTS -> var10000 = .getPants();
OVERPANTS -> var10000 = .getOverpants();
UNDERTOPS -> var10000 = .getUndertops();
OVERTOPS -> var10000 = .getOvertops();
HAIRCUTS -> var10000 = .getHaircuts();
SHOES -> var10000 = .getShoes();
HEAD_ACCESSORY -> var10000 = .getHeadAccessories();
FACE_ACCESSORY -> var10000 = .getFaceAccessories();
EAR_ACCESSORY -> var10000 = .getEarAccessories();
GLOVES -> var10000 = .getGloves();
CAPES -> var10000 = .getCapes();
SKIN_FEATURES -> var10000 = .getSkinFeatures();
-> ((String) , (Throwable) );
}
var10000;
}
}
com/hypixel/hytale/server/core/cosmetics/CosmeticType.java
package com.hypixel.hytale.server.core.cosmetics;
public enum CosmeticType {
EMOTES,
SKIN_TONES,
EYE_COLORS,
GRADIENT_SETS,
BODY_CHARACTERISTICS,
UNDERWEAR,
EYEBROWS,
EARS,
EYES,
FACE,
MOUTHS,
FACIAL_HAIR,
PANTS,
OVERPANTS,
UNDERTOPS,
OVERTOPS,
HAIRCUTS,
SHOES,
HEAD_ACCESSORY,
FACE_ACCESSORY,
EAR_ACCESSORY,
GLOVES,
CAPES,
SKIN_FEATURES;
private CosmeticType () {
}
}
com/hypixel/hytale/server/core/cosmetics/CosmeticsModule.java
package com.hypixel.hytale.server.core.cosmetics;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.common.util.RandomUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.Options;
import com.hypixel.hytale.server.core.asset.AssetModule;
import com.hypixel.hytale.server.core.asset.LoadAssetEvent;
import com.hypixel.hytale.server.core.asset.type.model.config.Model;
import com.hypixel.hytale.server.core.asset.type.model.config.ModelAsset;
import com.hypixel.hytale.server.core.cosmetics.commands.EmoteCommand;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class CosmeticsModule extends JavaPlugin {
public static final PluginManifest MANIFEST = PluginManifest.corePlugin(CosmeticsModule.class).build();
private static CosmeticsModule INSTANCE;
private CosmeticRegistry registry;
public CosmeticsModule (@Nonnull JavaPluginInit init) {
super (init);
INSTANCE = ;
}
{
.registry = (AssetModule.get().getBaseAssetPack());
.getCommandRegistry().registerCommand( ());
(Options.getOptionSet().has(Options.VALIDATE_ASSETS)) {
.getEventRegistry().register(( ) , LoadAssetEvent.class, ::validateGeneratedSkin);
}
}
CosmeticRegistry {
.registry;
}
{
( ; i < ; ++i) {
com.hypixel.hytale.protocol. .generateRandomSkin( (( )i));
{
.validateSkin(skin);
} (InvalidSkinException e) {
eventType.failed( , e.getMessage());
;
}
}
}
Model {
com.hypixel.hytale.protocol. .generateRandomSkin(random);
get().createModel(skin);
}
Model {
.createModel(skin, );
}
Model {
{
.validateSkin(skin);
} (InvalidSkinException e) {
((HytaleLogger.Api) .getLogger().at(Level.WARNING).withCause(e)).log( , skin);
;
}
(ModelAsset)ModelAsset.getAssetMap().getAsset( );
Model.createScaledModel(modelAsset, scale, (Map) );
}
InvalidSkinException {
(skin == ) {
( );
} (skin.face != && .registry.getFaces().containsKey(skin.face)) {
(skin.ears != && .registry.getEars().containsKey(skin.ears)) {
(skin.mouth != && .registry.getMouths().containsKey(skin.mouth)) {
(! .isValidAttachment( .registry.getBodyCharacteristics(), skin.bodyCharacteristic, )) {
( );
} (! .isValidAttachment( .registry.getUnderwear(), skin.underwear, )) {
( );
} (! .isValidAttachment( .registry.getEyes(), skin.eyes, )) {
( );
} (! .isValidAttachment( .registry.getSkinFeatures(), skin.skinFeature)) {
( );
} (! .isValidAttachment( .registry.getEyebrows(), skin.eyebrows)) {
( );
} (! .isValidAttachment( .registry.getPants(), skin.pants)) {
( );
} (! .isValidAttachment( .registry.getOverpants(), skin.overpants)) {
( );
} (! .isValidAttachment( .registry.getShoes(), skin.shoes)) {
( );
} (! .isValidAttachment( .registry.getUndertops(), skin.undertop)) {
( );
} (! .isValidAttachment( .registry.getOvertops(), skin.overtop)) {
( );
} (! .isValidAttachment( .registry.getGloves(), skin.gloves)) {
( );
} (! .isValidAttachment( .registry.getHeadAccessories(), skin.headAccessory)) {
( );
} (! .isValidAttachment( .registry.getFaceAccessories(), skin.faceAccessory)) {
( );
} (! .isValidAttachment( .registry.getEarAccessories(), skin.earAccessory)) {
( );
} (! .isValidHaircutAttachment(skin.haircut, skin.headAccessory)) {
( );
} (! .isValidAttachment( .registry.getFacialHairs(), skin.facialHair)) {
( );
} (! .isValidAttachment( .registry.getCapes(), skin.cape)) {
( );
}
} {
( );
}
} {
( );
}
} {
( );
}
}
{
.isValidAttachment(map, id, );
}
{
(part.getGradientSet() != && ((PlayerSkinGradientSet) .registry.getGradientSets().get(part.getGradientSet())).getGradients().containsKey(textureId)) {
;
} {
part.getVariants() != ? ((PlayerSkinPart.Variant)part.getVariants().get(variantId)).getTextures().containsKey(textureId) : part.getTextures().containsKey(textureId);
}
}
{
(id == ) {
!required;
} {
String[] idParts = id.split( );
(PlayerSkinPart)map.get(idParts[ ]);
(skinPart == ) {
;
} {
idParts.length > && !idParts[ ].isEmpty() ? idParts[ ] : ;
skinPart.getVariants() != && !skinPart.getVariants().containsKey(variantId) ? : .isValidTexture(skinPart, variantId, idParts[ ]);
}
}
}
{
(haircutId == ) {
;
} {
Map<String, PlayerSkinPart> haircuts = .registry.getHaircuts();
String[] idParts = haircutId.split( );
idParts[ ];
idParts.length > && !idParts[ ].isEmpty() ? idParts[ ] : ;
(headAccessoryId != ) {
idParts = headAccessoryId.split( );
idParts[ ];
(PlayerSkinPart) .registry.getHeadAccessories().get(headAccessoryAssetId);
(headAccessoryPart != ) {
(headAccessoryPart.getHeadAccessoryType()) {
HalfCovering:
(PlayerSkinPart)haircuts.get(haircutAssetId);
(haircutPart == ) {
;
}
(haircutPart.doesRequireGenericHaircut()) {
(PlayerSkinPart)haircuts.get( + String.valueOf(haircutPart.getHairType()));
.isValidAttachment(haircuts, baseHaircutPart.getId() + + haircutAssetTextureId, );
}
;
FullyCovering:
.isValidAttachment(haircuts, haircutId);
}
}
}
.isValidAttachment(haircuts, haircutId);
}
}
CosmeticsModule {
INSTANCE;
}
com.hypixel.hytale.protocol.PlayerSkin {
.randomSkinPart( .registry.getBodyCharacteristics(), , random);
.randomSkinPart( .registry.getUnderwear(), , random);
.randomSkinPart( .registry.getFaces(), , , random);
.randomSkinPart( .registry.getEars(), , , random);
.randomSkinPart( .registry.getMouths(), , , random);
.randomSkinPart( .registry.getEyes(), , random);
;
(random.nextInt( ) > ) {
facialHair = .randomSkinPart( .registry.getFacialHairs(), random);
}
.randomSkinPart( .registry.getHaircuts(), random);
.randomSkinPart( .registry.getEyebrows(), random);
.randomSkinPart( .registry.getPants(), random);
;
.randomSkinPart( .registry.getUndertops(), random);
.randomSkinPart( .registry.getOvertops(), random);
.randomSkinPart( .registry.getShoes(), random);
;
(random.nextInt( ) > ) {
headAccessory = .randomSkinPart( .registry.getHeadAccessories(), random);
}
;
(random.nextInt( ) > ) {
faceAccessory = .randomSkinPart( .registry.getFaceAccessories(), random);
}
;
(random.nextInt( ) > ) {
earAccessory = .randomSkinPart( .registry.getEarAccessories(), random);
}
;
(random.nextInt( ) > ) {
skinFeature = .randomSkinPart( .registry.getSkinFeatures(), random);
}
;
.hypixel.hytale.protocol.PlayerSkin(bodyCharacteristic, underwear, face, eyes, ears, mouth, facialHair, haircut, eyebrows, pants, overpants, undertop, overtop, shoes, headAccessory, faceAccessory, earAccessory, skinFeature, gloves, (String) );
}
String {
.randomSkinPart(map, , random);
}
String {
.randomSkinPart(map, required, , random);
}
String {
PlayerSkinPart[] arr = (PlayerSkinPart[])map.values().toArray((x$ ) -> [x$ ]);
required ? (PlayerSkinPart)RandomUtil.selectRandom(arr, random) : (PlayerSkinPart)RandomUtil.selectRandomOrNull(arr, random);
(part == ) {
;
} (!color) {
part.getId();
} {
String[] colors = ArrayUtil.EMPTY_STRING_ARRAY;
(part.getGradientSet() != ) {
colors = (String[])((PlayerSkinGradientSet) .registry.getGradientSets().get(part.getGradientSet())).getGradients().keySet().toArray((x$ ) -> [x$ ]);
}
Map<String, PlayerSkinPartTexture> textures = part.getTextures();
;
(part.getVariants() != ) {
variantId = (String)RandomUtil.selectRandom((String[])part.getVariants().keySet().toArray((x$ ) -> [x$ ]), random);
textures = ((PlayerSkinPart.Variant)part.getVariants().get(variantId)).getTextures();
}
(textures != ) {
colors = (String[])ArrayUtil.combine(colors, (String[])textures.keySet().toArray((x$ ) -> [x$ ]));
}
(String)RandomUtil.selectRandom(colors, random);
(variantId == ) {
part.getId();
var10000 + + colorId;
} {
part.getId() + + colorId + + variantId;
}
}
}
{
{
(message);
}
}
}
com/hypixel/hytale/server/core/cosmetics/Emote.java
package com.hypixel.hytale.server.core.cosmetics;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public class Emote {
protected String id;
protected String name;
protected String animation;
protected Emote (@Nonnull BsonDocument bson) {
this .id = bson.getString("Id" ).getValue();
this .name = bson.getString("Name" ).getValue();
this .animation = bson.getString("Animation" ).getValue();
}
public String getId () {
return this .id;
}
public String getName () {
return this .name;
}
public String getAnimation () {
return this .animation;
}
@Nonnull
public String toString () {
return "Emote{id='" + this .id + "', name='" + this .name + "', animation='" + this .animation + "'}" ;
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkin.java
package com.hypixel.hytale.server.core.cosmetics;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public class PlayerSkin {
private final PlayerSkinPartId bodyCharacteristic;
private final PlayerSkinPartId underwear;
private final String face;
private final String ears;
private final String mouth;
@Nullable
private final PlayerSkinPartId eyes;
@Nullable
private final PlayerSkinPartId facialHair;
@Nullable
private final PlayerSkinPartId haircut;
@Nullable
private final PlayerSkinPartId eyebrows;
@Nullable
private final PlayerSkinPartId pants;
@Nullable
private final PlayerSkinPartId overpants;
@Nullable
private final PlayerSkinPartId undertop;
@Nullable
private final PlayerSkinPartId overtop;
@Nullable
private final PlayerSkinPartId shoes;
PlayerSkinPartId headAccessory;
PlayerSkinPartId faceAccessory;
PlayerSkinPartId earAccessory;
PlayerSkinPartId skinFeature;
PlayerSkinPartId gloves;
PlayerSkinPartId cape;
{
.bodyCharacteristic = getId(doc, );
.underwear = getId(doc, );
.face = doc.getString( ).getValue();
.ears = doc.getString( ).getValue();
.mouth = doc.getString( ).getValue();
.eyes = PlayerSkin.PlayerSkinPartId.fromString(doc.getString( ).getValue());
.facialHair = getId(doc, );
.haircut = getId(doc, );
.eyebrows = getId(doc, );
.pants = getId(doc, );
.overpants = getId(doc, );
.undertop = getId(doc, );
.overtop = getId(doc, );
.shoes = getId(doc, );
.headAccessory = getId(doc, );
.faceAccessory = getId(doc, );
.earAccessory = getId(doc, );
.skinFeature = getId(doc, );
.gloves = getId(doc, );
.cape = getId(doc, );
}
{
.bodyCharacteristic = bodyCharacteristic;
.underwear = underwear;
.face = face;
.ears = ears;
.mouth = mouth;
.eyes = eyes;
.facialHair = facialHair;
.haircut = haircut;
.eyebrows = eyebrows;
.pants = pants;
.overpants = overpants;
.undertop = undertop;
.overtop = overtop;
.shoes = shoes;
.headAccessory = headAccessory;
.faceAccessory = faceAccessory;
.earAccessory = earAccessory;
.skinFeature = skinFeature;
.gloves = gloves;
.cape = cape;
}
{
.bodyCharacteristic = bodyCharacteristic != ? PlayerSkin.PlayerSkinPartId.fromString(bodyCharacteristic) : ;
.underwear = underwear != ? PlayerSkin.PlayerSkinPartId.fromString(underwear) : ;
.face = face;
.ears = ears;
.mouth = mouth;
.eyes = eyes != ? PlayerSkin.PlayerSkinPartId.fromString(eyes) : ;
.facialHair = facialHair != ? PlayerSkin.PlayerSkinPartId.fromString(facialHair) : ;
.haircut = haircut != ? PlayerSkin.PlayerSkinPartId.fromString(haircut) : ;
.eyebrows = eyebrows != ? PlayerSkin.PlayerSkinPartId.fromString(eyebrows) : ;
.pants = pants != ? PlayerSkin.PlayerSkinPartId.fromString(pants) : ;
.overpants = overpants != ? PlayerSkin.PlayerSkinPartId.fromString(overpants) : ;
.undertop = undertop != ? PlayerSkin.PlayerSkinPartId.fromString(undertop) : ;
.overtop = overtop != ? PlayerSkin.PlayerSkinPartId.fromString(overtop) : ;
.shoes = shoes != ? PlayerSkin.PlayerSkinPartId.fromString(shoes) : ;
.headAccessory = headAccessory != ? PlayerSkin.PlayerSkinPartId.fromString(headAccessory) : ;
.faceAccessory = faceAccessory != ? PlayerSkin.PlayerSkinPartId.fromString(faceAccessory) : ;
.earAccessory = earAccessory != ? PlayerSkin.PlayerSkinPartId.fromString(earAccessory) : ;
.skinFeature = skinFeature != ? PlayerSkin.PlayerSkinPartId.fromString(skinFeature) : ;
.gloves = gloves != ? PlayerSkin.PlayerSkinPartId.fromString(gloves) : ;
.cape = cape != ? PlayerSkin.PlayerSkinPartId.fromString(cape) : ;
}
PlayerSkinPartId {
doc.get(key);
bsonValue != && !bsonValue.isNull() ? PlayerSkin.PlayerSkinPartId.fromString(bsonValue.asString().getValue()) : ;
}
PlayerSkinPartId {
.bodyCharacteristic;
}
PlayerSkinPartId {
.underwear;
}
String {
.face;
}
PlayerSkinPartId {
.eyes;
}
String {
.ears;
}
String {
.mouth;
}
PlayerSkinPartId {
.facialHair;
}
PlayerSkinPartId {
.haircut;
}
PlayerSkinPartId {
.eyebrows;
}
PlayerSkinPartId {
.pants;
}
PlayerSkinPartId {
.overpants;
}
PlayerSkinPartId {
.undertop;
}
PlayerSkinPartId {
.overtop;
}
PlayerSkinPartId {
.shoes;
}
PlayerSkinPartId {
.headAccessory;
}
PlayerSkinPartId {
.faceAccessory;
}
PlayerSkinPartId {
.earAccessory;
}
PlayerSkinPartId {
.skinFeature;
}
PlayerSkinPartId {
.gloves;
}
PlayerSkinPartId {
.cape;
}
{
String assetId;
String textureId;
String variantId;
{
.assetId = assetId;
.textureId = textureId;
.variantId = variantId;
}
PlayerSkinPartId {
String[] idParts = stringId.split( );
(idParts[ ], idParts.length > ? idParts[ ] : , idParts.length > ? idParts[ ] : );
}
String {
.assetId;
}
String {
.textureId;
}
String {
.variantId;
}
String {
+ .assetId + + .textureId + + .variantId + ;
}
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkinGradient.java
package com.hypixel.hytale.server.core.cosmetics;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public class PlayerSkinGradient extends PlayerSkinTintColor {
private String texture;
protected PlayerSkinGradient (@Nonnull BsonDocument doc) {
super (doc);
if (doc.containsKey("Texture" )) {
this .texture = doc.getString("Texture" ).getValue();
}
}
public String getTexture () {
return this .texture;
}
@Nonnull
public String toString () {
String var10000 = this .texture;
return "PlayerSkinGradient{texture='" + var10000 + "', id='" + this .id + "', baseColor='" + String.valueOf(this .baseColor) + "'}" ;
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkinGradientSet.java
package com.hypixel.hytale.server.core.cosmetics;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public class PlayerSkinGradientSet {
private final String id;
private final Map<String, PlayerSkinPartTexture> gradients;
protected PlayerSkinGradientSet (@Nonnull BsonDocument doc) {
this .id = doc.getString("Id" ).getValue();
BsonDocument gradients = doc.getDocument("Gradients" );
this .gradients = new Object2ObjectOpenHashMap <String, PlayerSkinPartTexture>();
for (Map.Entry<String, BsonValue> gradient : gradients.entrySet()) {
this .gradients.put((String)gradient.getKey(), new PlayerSkinPartTexture (((BsonValue)gradient.getValue()).asDocument()));
}
}
public String getId () {
return this .id;
}
public Map<String, PlayerSkinPartTexture> getGradients () {
return this .gradients;
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkinPart.java
package com.hypixel.hytale.server.core.cosmetics;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Arrays;
import java.util.Map;
import javax.annotation.Nonnull;
import org.bson.BsonArray;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public class PlayerSkinPart {
private final String id;
private final String name;
private String model;
private String greyscaleTexture;
private String gradientSet;
private Map<String, PlayerSkinPartTexture> textures;
private Map<String, Variant> variants;
private boolean isDefaultAsset;
private String[] tags;
private HaircutType hairType;
private boolean requiresGenericHaircut;
@Nonnull
private HeadAccessoryType headAccessoryType;
protected PlayerSkinPart (@Nonnull BsonDocument doc) {
this .headAccessoryType = PlayerSkinPart.HeadAccessoryType.Simple;
this .id = doc.getString("Id" ).getValue();
this .name = doc.getString("Name" ).getValue();
if (doc.containsKey("Model" )) {
this .model = doc.getString("Model" ).getValue();
}
(doc.containsKey( )) {
.gradientSet = doc.getString( ).getValue();
}
(doc.containsKey( )) {
.greyscaleTexture = doc.getString( ).getValue();
}
(doc.containsKey( )) {
doc.getDocument( );
.variants = <String, Variant>();
(Map.Entry<String, BsonValue> set : mapping.entrySet()) {
.variants.put((String)set.getKey(), (((BsonValue)set.getValue()).asDocument()));
}
} (doc.containsKey( )) {
doc.getDocument( );
.textures = <String, PlayerSkinPartTexture>();
(Map.Entry<String, BsonValue> set : mapping.entrySet()) {
.textures.put((String)set.getKey(), (((BsonValue)set.getValue()).asDocument()));
}
}
(doc.containsKey( )) {
.isDefaultAsset = doc.getBoolean( ).getValue();
}
(doc.containsKey( )) {
doc.getArray( );
.tags = [bsonArray.size()];
( ; i < bsonArray.size(); ++i) {
.tags[i] = bsonArray.get(i).asString().getValue();
}
}
(doc.containsKey( )) {
.hairType = PlayerSkinPart.HaircutType.valueOf(doc.getString( ).getValue());
}
(doc.containsKey( )) {
.requiresGenericHaircut = doc.getBoolean( ).getValue();
}
(doc.containsKey( )) {
.headAccessoryType = PlayerSkinPart.HeadAccessoryType.valueOf(doc.getString( ).getValue());
}
}
String {
.id;
}
String {
.name;
}
String {
.model;
}
Map<String, PlayerSkinPartTexture> {
.textures;
}
Map<String, Variant> {
.variants;
}
{
.isDefaultAsset;
}
String[] getTags() {
.tags;
}
HaircutType {
.hairType;
}
{
.requiresGenericHaircut;
}
HeadAccessoryType {
.headAccessoryType;
}
String {
.greyscaleTexture;
}
String {
.gradientSet;
}
String {
.id;
+ var10000 + + .name + + .model + + .greyscaleTexture + + .gradientSet + + String.valueOf( .textures) + + String.valueOf( .variants) + + .isDefaultAsset + + Arrays.toString( .tags) + + String.valueOf( .hairType) + + .requiresGenericHaircut + + String.valueOf( .headAccessoryType) + ;
}
{
String model;
String greyscaleTexture;
Map<String, PlayerSkinPartTexture> textures;
{
.model = doc.getString( ).getValue();
(doc.containsKey( )) {
.greyscaleTexture = doc.getString( ).getValue();
}
(doc.containsKey( )) {
doc.getDocument( );
.textures = <String, PlayerSkinPartTexture>();
(Map.Entry<String, BsonValue> set : texturesDoc.entrySet()) {
.textures.put((String)set.getKey(), (((BsonValue)set.getValue()).asDocument()));
}
}
}
String {
.model;
}
String {
.greyscaleTexture;
}
Map<String, PlayerSkinPartTexture> {
.textures;
}
String {
.model;
+ var10000 + + .greyscaleTexture + + String.valueOf( .textures) + ;
}
}
{
Short,
Medium,
Long;
{
}
}
{
Simple,
HalfCovering,
FullyCovering;
{
}
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkinPartTexture.java
package com.hypixel.hytale.server.core.cosmetics;
import java.util.Arrays;
import javax.annotation.Nonnull;
import org.bson.BsonArray;
import org.bson.BsonDocument;
public class PlayerSkinPartTexture {
private String texture;
private String[] baseColor;
protected PlayerSkinPartTexture (@Nonnull BsonDocument doc) {
this .texture = doc.getString("Texture" ).getValue();
if (doc.containsKey("BaseColor" )) {
BsonArray baseColor = doc.getArray("BaseColor" );
this .baseColor = new String [baseColor.size()];
for (int i = 0 ; i < baseColor.size(); ++i) {
this .baseColor[i] = baseColor.get(i).asString().getValue();
}
}
}
public String getTexture () {
return this .texture;
}
public String[] getBaseColor() {
return this .baseColor;
}
@Nonnull
public String toString () {
String .texture;
+ var10000 + + Arrays.toString( .baseColor) + ;
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkinPartType.java
package com.hypixel.hytale.server.core.cosmetics;
public enum PlayerSkinPartType {
Eyes,
Ears,
Mouth,
Eyebrows,
Haircut,
FacialHair,
Pants,
Overpants,
Undertops,
Overtops,
Shoes,
HeadAccessory,
FaceAccessory,
EarAccessory,
SkinFeature,
Gloves;
private PlayerSkinPartType () {
}
}
com/hypixel/hytale/server/core/cosmetics/PlayerSkinTintColor.java
package com.hypixel.hytale.server.core.cosmetics;
import javax.annotation.Nonnull;
import org.bson.BsonArray;
import org.bson.BsonDocument;
public class PlayerSkinTintColor {
protected String id;
protected String[] baseColor;
protected PlayerSkinTintColor (@Nonnull BsonDocument doc) {
this .id = doc.getString("Id" ).getValue();
BsonArray baseColor = doc.getArray("BaseColor" );
this .baseColor = new String [baseColor.size()];
for (int i = 0 ; i < baseColor.size(); ++i) {
this .baseColor[i] = baseColor.get(i).asString().getValue();
}
}
public String getId () {
return this .id;
}
public String[] getBaseColor() {
return this .baseColor;
}
@Nonnull
public String toString () {
String var10000 = this .id;
return + var10000 + + String.valueOf( .baseColor) + ;
}
}
com/hypixel/hytale/server/core/cosmetics/commands/EmoteCommand.java
package com.hypixel.hytale.server.core.cosmetics.commands;
import com.hypixel.hytale.common.util.StringUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.protocol.AnimationSlot;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandUtil;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.cosmetics.CosmeticRegistry;
import com.hypixel.hytale.server.core.cosmetics.CosmeticsModule;
import com.hypixel.hytale.server.core.cosmetics.Emote;
import com.hypixel.hytale.server.core.entity.AnimationUtils;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.Map;
import javax.annotation.Nonnull;
public class EmoteCommand extends AbstractPlayerCommand {
@Nonnull
private final RequiredArg<String> emoteArg;
public EmoteCommand () {
super ("emote" , );
.emoteArg = .withRequiredArg( , , ArgTypes.STRING);
.setPermissionGroup(GameMode.Adventure);
}
{
CosmeticsModule.get().getRegistry();
Map<String, Emote> emotes = cosmeticsRegistry.getEmotes();
(String) .emoteArg.get(context);
(Emote)emotes.get(emoteId);
(emote == ) {
context.sendMessage(Message.translation( ).param( , emoteId));
context.sendMessage(Message.translation( ).param( , StringUtil.sortByFuzzyDistance(emoteId, emotes.keySet(), CommandUtil.RECOMMEND_COUNT).toString()));
} {
AnimationUtils.playAnimation(ref, AnimationSlot.Emote, (String) , emote.getId(), , store);
}
}
}
package com.hypixel.hytale.server.core.meta;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.DirectDecodeCodec;
import com.hypixel.hytale.codec.ExtraInfo;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.Map;
import java.util.function.BiConsumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public abstract class AbstractMetaStore <K> implements IMetaStoreImpl <K> {
protected final K parent;
protected final IMetaRegistry<K> registry;
@Nonnull
private final BsonDocument unknownValues;
@Nonnull
private final IntSet notUnknownKeys;
@Nullable
private BsonDocument cachedEncoded;
private boolean dirty;
private boolean bypassEncodedCache;
public AbstractMetaStore (K parent, IMetaRegistry<K> registry, boolean bypassEncodedCache) {
this .parent = parent;
this .registry = registry;
this .unknownValues = ();
.notUnknownKeys = ();
.dirty = ;
.bypassEncodedCache = bypassEncodedCache;
}
<T> T ;
IMetaStoreImpl<K> {
;
}
IMetaRegistry<K> {
.registry;
}
{
.unknownValues.forEach(consumer);
}
{
.dirty = ;
.cachedEncoded = ;
}
{
.dirty;
.dirty = ;
previous;
}
<T> T {
(T)(key PersistentMetaKey && .tryDecodeUnknownKey((PersistentMetaKey)key) ? .get0(key) : .registry.newMetaObject(key, .parent));
}
<T> {
(! .notUnknownKeys.add(key.getId())) {
;
} {
.unknownValues.get(key.getKey());
(value != ) {
Codec<T> codec = key.getCodec();
T obj;
(codec DirectDecodeCodec) {
obj = (T) .registry.newMetaObject(key, .parent);
((DirectDecodeCodec)codec).decode(value, obj, (ExtraInfo) );
} {
obj = codec.decode(value, (ExtraInfo) );
}
.unknownValues.remove(key.getKey());
.putMetaObject(key, obj);
;
} {
;
}
}
}
BsonDocument {
(! .bypassEncodedCache && .cachedEncoded != ) {
.cachedEncoded;
} {
();
document.putAll( .unknownValues);
.getRegistry().forEachMetaEntry( , .MetaEntryConsumer() {
<T> {
(key PersistentMetaKey<T> persistentKey) {
document.put(persistentKey.getKey(), persistentKey.getCodec().encode(value, extraInfo));
}
}
});
(! .bypassEncodedCache) {
.cachedEncoded = document;
}
document;
}
}
{
(!Codec.isNullBsonValue(document)) {
(Map.Entry<String, BsonValue> entry : document.entrySet()) {
(String)entry.getKey();
(BsonValue)entry.getValue();
.getRegistry().getMetaKeyForCodecKey(key);
(metaKey == ) {
.unknownValues.put(key, value);
} (metaKey.getCodec() DirectDecodeCodec) {
.registry.newMetaObject(metaKey, .parent);
((DirectDecodeCodec)metaKey.getCodec()).decode(value, obj, extraInfo);
.putMetaObject(metaKey, obj);
} {
.putMetaObject(metaKey, metaKey.getCodec().decode(value, extraInfo));
}
}
}
}
}
package com.hypixel.hytale.server.core.meta;
import com.hypixel.hytale.common.util.ArrayUtil;
import java.util.Arrays;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ArrayMetaStore <K> extends AbstractMetaStore <K> {
private static final Object NO_ENTRY = new Object ();
private Object[] array;
public ArrayMetaStore (K parent, IMetaRegistry<K> registry) {
this (parent, registry, false );
}
public ArrayMetaStore (K parent, IMetaRegistry<K> registry, boolean bypassEncodedCache) {
super (parent, registry, bypassEncodedCache);
this .array = ArrayUtil.emptyArray();
}
protected <T> T get0 (@Nonnull MetaKey<T> key) {
return (T)this .array[key.getId()];
}
public <T> T getMetaObject (@Nonnull MetaKey<T> key) {
int id = key.getId();
if (id >= this .array.length) {
(T) .decodeOrNewMetaObject(key);
.resizeArray(obj, id);
obj;
} {
(T) .get0(key);
(obj == NO_ENTRY) {
.array[id] = obj = (T) .decodeOrNewMetaObject(key);
}
obj;
}
}
<T> T {
(key.getId() >= .array.length) {
;
} {
(T) .get0(key);
(T)(oldObj != NO_ENTRY ? oldObj : );
}
}
<T> T {
.markMetaStoreDirty();
key.getId();
(id >= .array.length) {
.resizeArray(obj, id);
;
} {
(T) .array[id];
.array[id] = obj;
(T)(oldObj != NO_ENTRY ? oldObj : );
}
}
<T> T {
(key.getId() >= .array.length) {
;
} {
.markMetaStoreDirty();
(T) .array[key.getId()];
.array[key.getId()] = NO_ENTRY;
(T)(oldObj != NO_ENTRY ? oldObj : );
}
}
<T> T {
(key.getId() >= .array.length && key PersistentMetaKey) {
.tryDecodeUnknownKey((PersistentMetaKey)key);
}
(T) .removeMetaObject(key);
}
{
key.getId();
(id >= .array.length) {
;
} {
.array[id] != NO_ENTRY;
}
}
{
( ; i < .array.length; ++i) {
.array[i];
(o != NO_ENTRY) {
consumer.accept(i, o);
}
}
}
<T> {
Object[] arr = [id + ];
Arrays.fill(arr, .array.length, arr.length, NO_ENTRY);
System.arraycopy( .array, , arr, , .array.length);
arr[id] = obj;
.array = arr;
}
}
package com.hypixel.hytale.server.core.meta;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class DynamicMetaStore <K> extends AbstractMetaStore <K> {
@Nonnull
private final Int2ObjectMap<Object> map;
public DynamicMetaStore (K parent, IMetaRegistry<K> registry) {
this (parent, registry, false );
}
public DynamicMetaStore (K parent, IMetaRegistry<K> registry, boolean bypassEncodedCache) {
super (parent, registry, bypassEncodedCache);
this .map = new Int2ObjectOpenHashMap <Object>();
}
protected <T> T get0 (@Nonnull MetaKey<T> key) {
return (T)this .map.get(key.getId());
}
public <T> T getMetaObject (@Nonnull MetaKey<T> key) {
T o = (T)this .get0(key);
if (o == null ) {
this .map.put(key.getId(), o = (T) .decodeOrNewMetaObject(key));
}
o;
}
<T> T {
(T) .get0(key);
}
<T> T {
.markMetaStoreDirty();
(T) .map.put(key.getId(), obj);
}
<T> T {
.markMetaStoreDirty();
(T) .map.remove(key.getId());
}
<T> T {
.markMetaStoreDirty();
(key PersistentMetaKey) {
.tryDecodeUnknownKey((PersistentMetaKey)key);
}
(T) .removeMetaObject(key);
}
{
.map.containsKey(key.getId());
}
{
(Int2ObjectMap.Entry entry : .map.int2ObjectEntrySet()) {
consumer.accept(entry.getIntKey(), entry.getValue());
}
}
DynamicMetaStore<K> {
DynamicMetaStore<K> clone = <K>(parent, .registry);
clone.map.putAll( .map);
clone;
}
{
.markMetaStoreDirty();
( .registry != other.registry) {
( );
} {
.map.putAll(other.map);
}
}
}
package com.hypixel.hytale.server.core.meta;
import com.hypixel.hytale.codec.Codec;
import java.util.function.Function;
import javax.annotation.Nullable;
public interface IMetaRegistry <K> {
<T> T newMetaObject (MetaKey<T> var1, K var2) ;
void forEachMetaEntry (IMetaStore<K> var1, MetaEntryConsumer var2) ;
@Nullable
PersistentMetaKey<?> getMetaKeyForCodecKey(String var1);
<T> MetaKey<T> registerMetaObject (Function<K, T> var1, boolean var2, String var3, Codec<T> var4) ;
default <T> MetaKey<T> registerMetaObject (Function<K, T> supplier, String keyName, Codec<T> codec) {
return this .<T>registerMetaObject(supplier, true , keyName, codec);
}
default <T> MetaKey<T> registerMetaObject (Function<K, T> supplier) {
return this .<T>registerMetaObject(supplier, false , (String)null , (Codec)null );
}
default <T> MetaKey<T> registerMetaObject () {
return this .<T>registerMetaObject((parent) -> null );
}
@FunctionalInterface
public interface MetaEntryConsumer {
<T> void ;
}
}
package com.hypixel.hytale.server.core.meta;
import javax.annotation.Nullable;
public interface IMetaStore <K> {
IMetaStoreImpl<K> getMetaStore () ;
default <T> T getMetaObject (MetaKey<T> key) {
return (T)this .getMetaStore().getMetaObject(key);
}
@Nullable
default <T> T getIfPresentMetaObject (MetaKey<T> key) {
return (T)this .getMetaStore().getIfPresentMetaObject(key);
}
@Nullable
default <T> T putMetaObject (MetaKey<T> key, T obj) {
return (T)this .getMetaStore().putMetaObject(key, obj);
}
@Nullable
default <T> T removeMetaObject (MetaKey<T> key) {
return (T)this .getMetaStore().removeMetaObject(key);
}
@Nullable
default <T> T removeSerializedMetaObject (MetaKey<T> key) {
return (T)this .getMetaStore().removeSerializedMetaObject(key);
}
default boolean hasMetaObject (MetaKey<?> key) {
return this .getMetaStore().hasMetaObject(key);
}
{
.getMetaStore().forEachMetaObject(consumer);
}
{
.getMetaStore().markMetaStoreDirty();
}
{
.getMetaStore().consumeMetaStoreDirty();
}
{
<T> ;
}
}
package com.hypixel.hytale.server.core.meta;
import com.hypixel.hytale.codec.ExtraInfo;
import java.util.function.BiConsumer;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public interface IMetaStoreImpl <K> extends IMetaStore <K> {
IMetaRegistry<K> getRegistry () ;
void decode (BsonDocument var1, ExtraInfo var2) ;
BsonDocument encode (ExtraInfo var1) ;
void forEachUnknownEntry (BiConsumer<String, BsonValue> var1) ;
}
package com.hypixel.hytale.server.core.meta;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MetaKey <T> {
private final int id;
MetaKey(int id) {
this .id = id;
}
public int getId () {
return this .id;
}
public boolean equals (@Nullable Object o) {
if (this == o) {
return true ;
} else if (o != null && this .getClass() == o.getClass()) {
MetaKey<?> metaKey = (MetaKey)o;
return this .id == metaKey.id;
} else {
return false ;
}
}
public int hashCode () {
return this .id;
}
@Nonnull
public String toString () {
return "MetaKey{id=" + this .id + ;
}
}
package com.hypixel.hytale.server.core.meta;
import com.hypixel.hytale.codec.Codec;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MetaRegistry <K> implements IMetaRegistry <K> {
private final Map<String, MetaRegistryEntry> parameterMapping = new Object2ObjectOpenHashMap <String, MetaRegistryEntry>();
private final List<MetaRegistryEntry> suppliers = new ObjectArrayList <MetaRegistryEntry>();
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock ();
public MetaRegistry () {
}
public <T> MetaKey<T> registerMetaObject (Function<K, T> function, boolean persistent, String keyName, @Nonnull Codec<T> codec) {
this .lock.writeLock().lock();
MetaKey var8;
try {
if (persistent && codec == ) {
( );
}
.suppliers.size();
MetaKey<T> key;
(persistent) {
key = <T>(metaId, keyName, codec);
} {
key = <T>(metaId);
}
MetaRegistry<K>.MetaRegistryEntry<T> metaEntry = <T>(function, key);
.suppliers.add(metaEntry);
(persistent) {
( .parameterMapping.containsKey(keyName)) {
( + keyName);
}
.parameterMapping.put(keyName, metaEntry);
}
var8 = metaEntry.getKey();
} {
.lock.writeLock().unlock();
}
var8;
}
<T> T {
.lock.readLock().lock();
Object var3;
{
var3 = ((MetaRegistryEntry) .suppliers.get(key.getId())).getFunction().apply(parent);
} {
.lock.readLock().unlock();
}
(T)var3;
}
{
store.forEachMetaObject( .MetaEntryConsumer() {
<T> {
MetaRegistry<K>.MetaRegistryEntry<T> entry = (MetaRegistryEntry)MetaRegistry. .suppliers.get(id);
consumer.accept(entry.getKey(), value);
}
});
}
PersistentMetaKey<?> getMetaKeyForCodecKey(String codecKey) {
(MetaRegistryEntry) .parameterMapping.get(codecKey);
entry == ? : (PersistentMetaKey)entry.getKey();
}
<T> {
Function<K, T> function;
MetaKey<T> key;
{
.function = function;
.key = key;
}
Function<K, T> {
.function;
}
MetaKey<T> {
.key;
}
}
}
package com.hypixel.hytale.server.core.meta;
import com.hypixel.hytale.codec.Codec;
import javax.annotation.Nonnull;
public class PersistentMetaKey <T> extends MetaKey <T> {
private final String key;
private final Codec<T> codec;
PersistentMetaKey(int id, String key, Codec<T> codec) {
super (id);
this .key = key;
this .codec = codec;
}
public String getKey () {
return this .key;
}
public Codec<T> getCodec () {
return this .codec;
}
@Nonnull
public String toString () {
String var10000 = this .key;
return "PersistentMetaKey{key=" + var10000 + "codec=" + String.valueOf(this .codec) + "}" ;
}
}
com/hypixel/hytale/server/core/permissions/HytalePermissions.java
package com.hypixel.hytale.server.core.permissions;
import javax.annotation.Nonnull;
public class HytalePermissions {
public static final String NAMESPACE = "hytale" ;
public static final String COMMAND_BASE = "hytale.command" ;
public static final String ASSET_EDITOR = "hytale.editor.asset" ;
public static final String ASSET_EDITOR_PACKS_CREATE = "hytale.editor.packs.create" ;
public static final String ASSET_EDITOR_PACKS_EDIT = "hytale.editor.packs.edit" ;
public static final String ASSET_EDITOR_PACKS_DELETE = "hytale.editor.packs.delete" ;
public static final String ;
;
;
;
;
;
;
;
;
;
{
}
String {
+ name;
}
String {
+ name + + subCommand;
}
}
com/hypixel/hytale/server/core/permissions/PermissionHolder.java
package com.hypixel.hytale.server.core.permissions;
import javax.annotation.Nonnull;
public interface PermissionHolder {
boolean hasPermission (@Nonnull String var1) ;
boolean hasPermission (@Nonnull String var1, boolean var2) ;
}
com/hypixel/hytale/server/core/permissions/PermissionsModule.java
package com.hypixel.hytale.server.core.permissions;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.command.system.CommandManager;
import com.hypixel.hytale.server.core.command.system.CommandRegistry;
import com.hypixel.hytale.server.core.event.events.permissions.GroupPermissionChangeEvent;
import com.hypixel.hytale.server.core.event.events.permissions.PlayerGroupEvent;
import com.hypixel.hytale.server.core.event.events.permissions.PlayerPermissionChangeEvent;
import com.hypixel.hytale.server.core.permissions.commands.PermCommand;
import com.hypixel.hytale.server.core.permissions.commands.op.OpCommand;
import com.hypixel.hytale.server.core.permissions.provider.HytalePermissionsProvider;
import com.hypixel.hytale.server.core.permissions.provider.PermissionProvider;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PermissionsModule extends JavaPlugin {
@Nonnull
PluginManifest.corePlugin(PermissionsModule.class).build();
PermissionsModule instance;
();
Map<String, Set<String>> virtualGroups = Object2ObjectMaps.<String, Set<String>>emptyMap();
List<PermissionProvider> providers = <PermissionProvider>() {
{
.add(PermissionsModule. .standardProvider);
}
};
PermissionsModule {
instance;
}
{
(init);
instance = ;
}
{
.getCommandRegistry();
commandRegistry.registerCommand( ());
commandRegistry.registerCommand( ());
}
{
Map<String, Set<String>> virtualGroups = CommandManager.get().createVirtualPermissionGroups();
((Set)virtualGroups.computeIfAbsent(GameMode.Creative.toString(), (k) -> ())).add( );
.setVirtualGroups(virtualGroups);
.standardProvider.syncLoad();
}
{
.providers.add(permissionProvider);
}
{
.providers.remove(provider);
}
List<PermissionProvider> {
Collections.unmodifiableList( .providers);
}
PermissionProvider {
(PermissionProvider) .providers.getFirst();
}
{
.providers.size() != || .providers.getFirst() != .standardProvider;
}
{
.getFirstPermissionProvider().addUserPermissions(uuid, permissions);
HytaleServer.get().getEventBus().dispatchFor(PlayerPermissionChangeEvent.PermissionsAdded.class).dispatch( .PermissionsAdded(uuid, permissions));
}
{
.getFirstPermissionProvider().removeUserPermissions(uuid, permissions);
HytaleServer.get().getEventBus().dispatchFor(PlayerPermissionChangeEvent.PermissionsRemoved.class).dispatch( .PermissionsRemoved(uuid, permissions));
}
{
.getFirstPermissionProvider().addGroupPermissions(group, permissions);
HytaleServer.get().getEventBus().dispatchFor(GroupPermissionChangeEvent.Added.class).dispatch( .Added(group, permissions));
}
{
.getFirstPermissionProvider().removeGroupPermissions(group, permissions);
HytaleServer.get().getEventBus().dispatchFor(GroupPermissionChangeEvent.Removed.class).dispatch( .Removed(group, permissions));
}
{
.getFirstPermissionProvider().addUserToGroup(uuid, group);
HytaleServer.get().getEventBus().dispatchFor(PlayerGroupEvent.Added.class).dispatch( .Added(uuid, group));
}
{
.getFirstPermissionProvider().removeUserFromGroup(uuid, group);
HytaleServer.get().getEventBus().dispatchFor(PlayerGroupEvent.Removed.class).dispatch( .Removed(uuid, group));
}
{
.virtualGroups = <String, Set<String>>(virtualGroups);
}
Set<String> {
Set<String> groups = ;
(PermissionProvider permissionProvider : .providers) {
Set<String> providerGroups = permissionProvider.getGroupsForUser(uuid);
(!providerGroups.isEmpty()) {
(groups == ) {
groups = ();
}
groups.addAll(providerGroups);
}
}
groups != ? Collections.unmodifiableSet(groups) : Collections.emptySet();
}
{
.hasPermission(uuid, id, );
}
{
(PermissionProvider permissionProvider : .providers) {
Set<String> userNodes = permissionProvider.getUserPermissions(uuid);
hasPermission(userNodes, id);
(userHasPerm != ) {
userHasPerm;
}
(String group : permissionProvider.getGroupsForUser(uuid)) {
Set<String> groupNodes = permissionProvider.getGroupPermissions(group);
hasPermission(groupNodes, id);
(groupHasPerm != ) {
groupHasPerm;
}
Set<String> virtualNodes = (Set) .virtualGroups.get(group);
hasPermission(virtualNodes, id);
(virtualHasPerm != ) {
virtualHasPerm;
}
}
}
def;
}
Boolean {
(nodes == ) {
;
} (nodes.contains( )) {
Boolean.TRUE;
} (nodes.contains( )) {
Boolean.FALSE;
} (nodes.contains(id)) {
Boolean.TRUE;
} (nodes.contains( + id)) {
Boolean.FALSE;
} {
String[] split = id.split( );
();
( ; i < split.length; ++i) {
(i > ) {
completeTrace.append( );
}
completeTrace.append(split[i]);
(nodes.contains(String.valueOf(completeTrace) + )) {
Boolean.TRUE;
}
(nodes.contains( + completeTrace.toString() + )) {
Boolean.FALSE;
}
}
;
}
}
}
com/hypixel/hytale/server/core/permissions/commands/PermCommand.java
package com.hypixel.hytale.server.core.permissions.commands;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
public class PermCommand extends AbstractCommandCollection {
public PermCommand () {
super ("perm" , "server.commands.perm.desc" );
this .addSubCommand(new PermGroupCommand ());
this .addSubCommand(new PermUserCommand ());
this .addSubCommand(new PermTestCommand ());
}
}
com/hypixel/hytale/server/core/permissions/commands/PermGroupCommand.java
package com.hypixel.hytale.server.core.permissions.commands;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.permissions.provider.PermissionProvider;
import com.hypixel.hytale.server.core.util.message.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
public class PermGroupCommand extends AbstractCommandCollection {
public PermGroupCommand () {
super ("group" , "server.commands.perm.group.desc" );
this .addSubCommand(new PermGroupListCommand ());
this .addSubCommand(new PermGroupAddCommand ());
this .addSubCommand(new PermGroupRemoveCommand ());
}
{
RequiredArg<String> groupArg;
{
( , );
.groupArg = .withRequiredArg( , , ArgTypes.STRING);
}
{
(String) .groupArg.get(context);
(PermissionProvider permissionProvider : PermissionsModule.get().getProviders()) {
Message.raw(permissionProvider.getName());
Set<Message> groupPermissions = (Set)permissionProvider.getGroupPermissions(group).stream().map(Message::raw).collect(Collectors.toSet());
context.sendMessage(MessageFormat.list(header, groupPermissions));
}
}
}
{
RequiredArg<String> groupArg;
RequiredArg<List<String>> permissionsArg;
{
( , );
.groupArg = .withRequiredArg( , , ArgTypes.STRING);
.permissionsArg = .withListRequiredArg( , , ArgTypes.STRING);
}
{
(String) .groupArg.get(context);
HashSet<String> permissions = ((Collection) .permissionsArg.get(context));
PermissionsModule.get().addGroupPermission(group, permissions);
context.sendMessage(Message.translation( ).param( , group));
}
}
{
RequiredArg<String> groupArg;
RequiredArg<List<String>> permissionsArg;
{
( , );
.groupArg = .withRequiredArg( , , ArgTypes.STRING);
.permissionsArg = .withListRequiredArg( , , ArgTypes.STRING);
}
{
(String) .groupArg.get(context);
HashSet<String> permissions = ((Collection) .permissionsArg.get(context));
PermissionsModule.get().removeGroupPermission(group, permissions);
context.sendMessage(Message.translation( ).param( , group));
}
}
}
com/hypixel/hytale/server/core/permissions/commands/PermTestCommand.java
package com.hypixel.hytale.server.core.permissions.commands;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import java.util.List;
import javax.annotation.Nonnull;
public class PermTestCommand extends CommandBase {
@Nonnull
private final RequiredArg<List<String>> nodesArg;
public PermTestCommand () {
super ("test" , "server.commands.testperm.desc" );
this .nodesArg = this .withListRequiredArg("nodes" , "server.commands.perm.test.nodes.desc" , ArgTypes.STRING);
}
protected void executeSync (@Nonnull CommandContext context) {
CommandSender sender = context.sender();
for (String node : (List)this .nodesArg.get(context)) {
context.sendMessage(Message.translation("server.commands.testperm.hasPermission" ).param("permission" , node).param( , sender.hasPermission(node)));
}
}
}
com/hypixel/hytale/server/core/permissions/commands/PermUserCommand.java
package com.hypixel.hytale.server.core.permissions.commands;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.permissions.provider.PermissionProvider;
import com.hypixel.hytale.server.core.util.message.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
public class PermUserCommand extends AbstractCommandCollection {
public PermUserCommand () {
super ("user" , "server.commands.perm.user.desc" );
this .addSubCommand(new PermUserListCommand ());
this .addSubCommand(new PermUserAddCommand ());
this .addSubCommand(new PermUserRemoveCommand ());
.addSubCommand( ());
}
{
RequiredArg<UUID> uuidArg;
{
( , );
.uuidArg = .withRequiredArg( , , ArgTypes.UUID);
}
{
(UUID) .uuidArg.get(context);
(PermissionProvider permissionProvider : PermissionsModule.get().getProviders()) {
Message.raw(permissionProvider.getName());
Set<Message> userPermissions = (Set)permissionProvider.getUserPermissions(uuid).stream().map(Message::raw).collect(Collectors.toSet());
context.sendMessage(MessageFormat.list(header, userPermissions));
}
}
}
{
RequiredArg<UUID> uuidArg;
RequiredArg<List<String>> permissionsArg;
{
( , );
.uuidArg = .withRequiredArg( , , ArgTypes.UUID);
.permissionsArg = .withListRequiredArg( , , ArgTypes.STRING);
}
{
(UUID) .uuidArg.get(context);
HashSet<String> permissions = ((Collection) .permissionsArg.get(context));
PermissionsModule.get().addUserPermission(uuid, permissions);
context.sendMessage(Message.translation( ).param( , uuid.toString()));
}
}
{
RequiredArg<UUID> uuidArg;
RequiredArg<List<String>> permissionsArg;
{
( , );
.uuidArg = .withRequiredArg( , , ArgTypes.UUID);
.permissionsArg = .withListRequiredArg( , , ArgTypes.STRING);
}
{
(UUID) .uuidArg.get(context);
HashSet<String> permissions = ((Collection) .permissionsArg.get(context));
PermissionsModule.get().removeUserPermission(uuid, permissions);
context.sendMessage(Message.translation( ).param( , uuid.toString()));
}
}
{
{
( , );
.addSubCommand( ());
.addSubCommand( ());
.addSubCommand( ());
}
{
RequiredArg<UUID> uuidArg;
{
( , );
.uuidArg = .withRequiredArg( , , ArgTypes.UUID);
}
{
(UUID) .uuidArg.get(context);
(PermissionProvider permissionProvider : PermissionsModule.get().getProviders()) {
Message.raw(permissionProvider.getName());
Set<Message> groups = (Set)permissionProvider.getGroupsForUser(uuid).stream().map(Message::raw).collect(Collectors.toSet());
context.sendMessage(MessageFormat.list(header, groups));
}
}
}
{
RequiredArg<UUID> uuidArg;
RequiredArg<String> groupArg;
{
( , );
.uuidArg = .withRequiredArg( , , ArgTypes.UUID);
.groupArg = .withRequiredArg( , , ArgTypes.STRING);
}
{
(UUID) .uuidArg.get(context);
(String) .groupArg.get(context);
PermissionsModule.get().addUserToGroup(uuid, group);
context.sendMessage(Message.translation( ).param( , uuid.toString()).param( , group));
}
}
{
RequiredArg<UUID> uuidArg;
RequiredArg<String> groupArg;
{
( , );
.uuidArg = .withRequiredArg( , , ArgTypes.UUID);
.groupArg = .withRequiredArg( , , ArgTypes.STRING);
}
{
(UUID) .uuidArg.get(context);
(String) .groupArg.get(context);
PermissionsModule.get().removeUserFromGroup(uuid, group);
context.sendMessage(Message.translation( ).param( , uuid.toString()).param( , group));
}
}
}
}
com/hypixel/hytale/server/core/permissions/commands/op/OpAddCommand.java
package com.hypixel.hytale.server.core.permissions.commands.op;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.permissions.HytalePermissions;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
public class OpAddCommand extends CommandBase {
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_ADDED = Message.translation("server.commands.op.added" );
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_ADDED_TARGET = Message.translation("server.commands.op.added.target" );
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_ALREADY Message.translation( );
RequiredArg<UUID> playerArg;
{
( , );
.playerArg = .withRequiredArg( , , ArgTypes.PLAYER_UUID);
.requirePermission(HytalePermissions.fromCommand( ));
}
{
(UUID) .playerArg.get(context);
PermissionsModule.get();
;
Universe.get().getPlayer(uuid);
playerRef != ? playerRef.getUsername() : uuid.toString();
Message.raw(displayName).bold( );
Set<String> groups = permissionsModule.getGroupsForUser(uuid);
(groups.contains( )) {
context.sendMessage(MESSAGE_COMMANDS_OP_ALREADY.param( , displayMessage));
} {
permissionsModule.addUserToGroup(uuid, );
context.sendMessage(MESSAGE_COMMANDS_OP_ADDED.param( , displayMessage));
(playerRef != ) {
playerRef.sendMessage(MESSAGE_COMMANDS_OP_ADDED_TARGET);
}
}
}
}
com/hypixel/hytale/server/core/permissions/commands/op/OpCommand.java
package com.hypixel.hytale.server.core.permissions.commands.op;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
public class OpCommand extends AbstractCommandCollection {
public OpCommand () {
super ("op" , "server.commands.op.desc" );
this .addSubCommand(new OpSelfCommand ());
this .addSubCommand(new OpAddCommand ());
this .addSubCommand(new OpRemoveCommand ());
}
protected boolean canGeneratePermission () {
return false ;
}
}
com/hypixel/hytale/server/core/permissions/commands/op/OpRemoveCommand.java
package com.hypixel.hytale.server.core.permissions.commands.op;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.permissions.HytalePermissions;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
public class OpRemoveCommand extends CommandBase {
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_REMOVED = Message.translation("server.commands.op.removed" );
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_REMOVED_TARGET = Message.translation("server.commands.op.removed.target" );
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_NOT_OP Message.translation( );
RequiredArg<UUID> playerArg;
{
( , );
.playerArg = .withRequiredArg( , , ArgTypes.PLAYER_UUID);
.requirePermission(HytalePermissions.fromCommand( ));
}
{
(UUID) .playerArg.get(context);
PermissionsModule.get();
;
Universe.get().getPlayer(uuid);
playerRef != ? playerRef.getUsername() : uuid.toString();
Message.raw(displayName).bold( );
Set<String> groups = permissionsModule.getGroupsForUser(uuid);
(groups.contains( )) {
permissionsModule.removeUserFromGroup(uuid, );
context.sendMessage(MESSAGE_COMMANDS_OP_REMOVED.param( , displayMessage));
(playerRef != ) {
playerRef.sendMessage(MESSAGE_COMMANDS_OP_REMOVED_TARGET);
}
} {
context.sendMessage(MESSAGE_COMMANDS_OP_NOT_OP.param( , displayMessage));
}
}
}
com/hypixel/hytale/server/core/permissions/commands/op/OpSelfCommand.java
package com.hypixel.hytale.server.core.permissions.commands.op;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Constants;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
public class OpSelfCommand extends AbstractPlayerCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_ADDED = Message.translation("server.commands.op.self.added" );
@Nonnull
private static final Message MESSAGE_COMMANDS_OP_REMOVED = Message.translation("server.commands.op.self.removed" );
@Nonnull
private static Message.translation( );
Message.translation( );
Message.translation( );
{
( , );
}
{
;
}
{
(PermissionsModule.get().areProvidersTampered()) {
playerRef.sendMessage(MESSAGE_COMMANDS_NON_VANILLA_PERMISSIONS);
} (Constants.SINGLEPLAYER && !SingleplayerModule.isOwner(playerRef)) {
playerRef.sendMessage(MESSAGE_COMMANDS_SINGLEPLAYER_OWNER_REQ);
} (!Constants.SINGLEPLAYER && !Constants.ALLOWS_SELF_OP_COMMAND) {
playerRef.sendMessage(MESSAGE_COMMANDS_MULTIPLAYER_TIP.param( , ).param( , ).param( , ));
} {
playerRef.getUuid();
PermissionsModule.get();
;
Set<String> groups = perms.getGroupsForUser(uuid);
(groups.contains( )) {
perms.removeUserFromGroup(uuid, );
context.sendMessage(MESSAGE_COMMANDS_OP_REMOVED);
} {
perms.addUserToGroup(uuid, );
context.sendMessage(MESSAGE_COMMANDS_OP_ADDED);
}
}
}
}
com/hypixel/hytale/server/core/permissions/provider/HytalePermissionsProvider.java
package com.hypixel.hytale.server.core.permissions.provider;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.hypixel.hytale.server.core.util.io.BlockingDiskFile;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
public final class HytalePermissionsProvider extends BlockingDiskFile implements PermissionProvider {
@Nonnull
public static final String DEFAULT_GROUP = "Default" ;
@Nonnull
public static Set<String> DEFAULT_GROUP_LIST = Set.of( );
;
Map<String, Set<String>> DEFAULT_GROUPS = Map.ofEntries(Map.entry( , Set.of( )), Map.entry( , Set.of()));
( ()).setPrettyPrinting().create();
;
Map<UUID, Set<String>> userPermissions = <UUID, Set<String>>();
Map<String, Set<String>> groupPermissions = <String, Set<String>>();
Map<UUID, Set<String>> userGroups = <UUID, Set<String>>();
{
(Paths.get( ));
}
String {
;
}
{
.fileLock.writeLock().lock();
{
Set<String> set = (Set) .userPermissions.computeIfAbsent(uuid, (k) -> ());
(set.addAll(permissions)) {
.syncSave();
}
} {
.fileLock.writeLock().unlock();
}
}
{
.fileLock.writeLock().lock();
{
Set<String> set = (Set) .userPermissions.get(uuid);
(set != ) {
set.removeAll(permissions);
(set.isEmpty()) {
.userPermissions.remove(uuid);
}
(hasChanges) {
.syncSave();
}
}
} {
.fileLock.writeLock().unlock();
}
}
Set<String> {
.fileLock.readLock().lock();
Set var3;
{
Set<String> set = (Set) .userPermissions.get(uuid);
(set != ) {
var3 = Collections.unmodifiableSet(set);
var3;
}
var3 = Collections.emptySet();
} {
.fileLock.readLock().unlock();
}
var3;
}
{
.fileLock.writeLock().lock();
{
Set<String> set = (Set) .groupPermissions.computeIfAbsent(group, (k) -> ());
(set.addAll(permissions)) {
.syncSave();
}
} {
.fileLock.writeLock().unlock();
}
}
{
.fileLock.writeLock().lock();
{
Set<String> set = (Set) .groupPermissions.get(group);
(set != ) {
set.removeAll(permissions);
(set.isEmpty()) {
.groupPermissions.remove(group);
}
(hasChanges) {
.syncSave();
}
}
} {
.fileLock.writeLock().unlock();
}
}
Set<String> {
.fileLock.readLock().lock();
Set var3;
{
Set<String> set = (Set) .groupPermissions.get(group);
(set != ) {
var3 = Collections.unmodifiableSet(set);
var3;
}
var3 = Collections.emptySet();
} {
.fileLock.readLock().unlock();
}
var3;
}
{
.fileLock.writeLock().lock();
{
Set<String> list = (Set) .userGroups.computeIfAbsent(uuid, (k) -> ());
(list.add(group)) {
.syncSave();
}
} {
.fileLock.writeLock().unlock();
}
}
{
.fileLock.writeLock().lock();
{
Set<String> list = (Set) .userGroups.get(uuid);
(list != ) {
list.remove(group);
(list.isEmpty()) {
.userGroups.remove(uuid);
}
(hasChanges) {
.syncSave();
}
}
} {
.fileLock.writeLock().unlock();
}
}
Set<String> {
.fileLock.readLock().lock();
Set var3;
{
Set<String> list = (Set) .userGroups.get(uuid);
(list != ) {
var3 = Collections.unmodifiableSet(list);
var3;
}
var3 = DEFAULT_GROUP_LIST;
} {
.fileLock.readLock().unlock();
}
var3;
}
IOException {
(fileReader);
{
JsonParser.parseReader(jsonReader).getAsJsonObject();
.userPermissions.clear();
.groupPermissions.clear();
.userGroups.clear();
(root.has( )) {
root.getAsJsonObject( );
(Map.Entry<String, JsonElement> entry : users.entrySet()) {
UUID.fromString((String)entry.getKey());
((JsonElement)entry.getValue()).getAsJsonObject();
(user.has( )) {
Set<String> set = ();
.userPermissions.put(uuid, set);
user.getAsJsonArray( ).forEach((e) -> set.add(e.getAsString()));
}
(user.has( )) {
Set<String> list = ();
.userGroups.put(uuid, list);
user.getAsJsonArray( ).forEach((e) -> list.add(e.getAsString()));
}
}
}
(root.has( )) {
root.getAsJsonObject( );
(Map.Entry<String, JsonElement> entry : groups.entrySet()) {
Set<String> set = ();
.groupPermissions.put((String)entry.getKey(), set);
((JsonElement)entry.getValue()).getAsJsonArray().forEach((e) -> set.add(e.getAsString()));
}
}
(Map.Entry<String, Set<String>> entry : DEFAULT_GROUPS.entrySet()) {
.groupPermissions.put((String)entry.getKey(), ((Collection)entry.getValue()));
}
} (Throwable var11) {
{
jsonReader.close();
} (Throwable var10) {
var11.addSuppressed(var10);
}
var11;
}
jsonReader.close();
}
IOException {
();
();
(Map.Entry<UUID, Set<String>> entry : .userPermissions.entrySet()) {
();
(Set)entry.getValue();
Objects.requireNonNull(asArray);
var10000.forEach(asArray::add);
((UUID)entry.getKey()).toString();
(!usersObj.has(memberName)) {
usersObj.add(memberName, ());
}
usersObj.getAsJsonObject(memberName).add( , asArray);
}
(Map.Entry<UUID, Set<String>> entry : .userGroups.entrySet()) {
();
(Set)entry.getValue();
Objects.requireNonNull(asArray);
var16.forEach(asArray::add);
((UUID)entry.getKey()).toString();
(!usersObj.has(memberName)) {
usersObj.add(memberName, ());
}
usersObj.getAsJsonObject(memberName).add( , asArray);
}
(!usersObj.isEmpty()) {
root.add( , usersObj);
}
();
(Map.Entry<String, Set<String>> entry : .groupPermissions.entrySet()) {
();
(Set)entry.getValue();
Objects.requireNonNull(asArray);
var17.forEach(asArray::add);
groupsObj.add((String)entry.getKey(), asArray);
}
(!groupsObj.isEmpty()) {
root.add( , groupsObj);
}
fileWriter.write(GSON.toJson((JsonElement)root));
}
IOException {
(fileWriter);
{
jsonWriter.beginObject();
jsonWriter.endObject();
} (Throwable var6) {
{
jsonWriter.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
var6;
}
jsonWriter.close();
}
}
com/hypixel/hytale/server/core/permissions/provider/PermissionProvider.java
package com.hypixel.hytale.server.core.permissions.provider;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
public interface PermissionProvider {
@Nonnull
String getName () ;
void addUserPermissions (@Nonnull UUID var1, @Nonnull Set<String> var2) ;
void removeUserPermissions (@Nonnull UUID var1, @Nonnull Set<String> var2) ;
Set<String> getUserPermissions (@Nonnull UUID var1) ;
void addGroupPermissions (@Nonnull String var1, @Nonnull Set<String> var2) ;
void removeGroupPermissions (@Nonnull String var1, @Nonnull Set<String> var2) ;
Set<String> getGroupPermissions (@Nonnull String var1) ;
void addUserToGroup (@Nonnull UUID var1, @Nonnull String var2) ;
void removeUserFromGroup (@Nonnull UUID var1, @Nonnull String var2) ;
Set<String> getGroupsForUser ;
}
com/hypixel/hytale/server/core/receiver/IEventTitleReceiver.java
package com.hypixel.hytale.server.core.receiver;
import com.hypixel.hytale.server.core.Message;
public interface IEventTitleReceiver {
float DEFAULT_DURATION = 4.0F ;
float DEFAULT_FADE_DURATION = 1.5F ;
default void showEventTitle (Message primaryTitle, Message secondaryTitle, boolean isMajor, String icon) {
this .showEventTitle(primaryTitle, secondaryTitle, isMajor, icon, 4.0F );
}
default void showEventTitle (Message primaryTitle, Message secondaryTitle, boolean isMajor, String icon, float duration) {
this .showEventTitle(primaryTitle, secondaryTitle, isMajor, icon, duration, 1.5F , 1.5F );
}
void showEventTitle (Message var1, Message var2, boolean var3, String var4, float var5, float var6, float var7) ;
default void hideEventTitle () {
this .hideEventTitle(1.5F );
}
void hideEventTitle ( var1) ;
}
com/hypixel/hytale/server/core/receiver/IMessageReceiver.java
package com.hypixel.hytale.server.core.receiver;
import com.hypixel.hytale.server.core.Message;
import javax.annotation.Nonnull;
public interface IMessageReceiver {
void sendMessage (@Nonnull Message var1) ;
}
com/hypixel/hytale/server/core/receiver/IPacketReceiver.java
package com.hypixel.hytale.server.core.receiver;
import com.hypixel.hytale.protocol.Packet;
import javax.annotation.Nonnull;
public interface IPacketReceiver {
void write (@Nonnull Packet var1) ;
void writeNoCache (@Nonnull Packet var1) ;
}
com/hypixel/hytale/server/core/registry/ClientFeatureRegistration.java
package com.hypixel.hytale.server.core.registry;
import com.hypixel.hytale.protocol.packets.setup.ClientFeature;
import com.hypixel.hytale.registry.Registration;
import com.hypixel.hytale.server.core.client.ClientFeatureHandler;
import java.util.function.BooleanSupplier;
import javax.annotation.Nonnull;
public class ClientFeatureRegistration extends Registration {
private final ClientFeature feature;
public ClientFeatureRegistration (@Nonnull ClientFeatureRegistration registration, BooleanSupplier isEnabled, Runnable unregister) {
this (registration.feature, isEnabled, unregister);
}
public ClientFeatureRegistration (ClientFeature feature) {
super (() -> true , () -> ClientFeatureHandler.unregister(feature));
this .feature = feature;
}
public ClientFeatureRegistration (ClientFeature feature, BooleanSupplier isEnabled, Runnable unregister) {
super (isEnabled, unregister);
this .feature = feature;
}
public ClientFeature getFeature () {
return this .feature;
}
}
com/hypixel/hytale/server/core/registry/ClientFeatureRegistry.java
package com.hypixel.hytale.server.core.registry;
import com.hypixel.hytale.assetstore.AssetRegistry;
import com.hypixel.hytale.function.consumer.BooleanConsumer;
import com.hypixel.hytale.protocol.packets.setup.ClientFeature;
import com.hypixel.hytale.protocol.packets.setup.ServerTags;
import com.hypixel.hytale.registry.Registry;
import com.hypixel.hytale.server.core.client.ClientFeatureHandler;
import com.hypixel.hytale.server.core.plugin.PluginBase;
import com.hypixel.hytale.server.core.universe.Universe;
import java.util.List;
import java.util.function.BooleanSupplier;
import javax.annotation.Nonnull;
public class ClientFeatureRegistry extends Registry <ClientFeatureRegistration> {
public ClientFeatureRegistry (@Nonnull List<BooleanConsumer> registrations, BooleanSupplier precondition, String preconditionMessage, PluginBase plugin) {
super (registrations, precondition, preconditionMessage, ClientFeatureRegistration::new );
}
public ClientFeatureRegistration register (ClientFeature feature) {
ClientFeatureHandler.register(feature);
return (ClientFeatureRegistration)super .register(new ClientFeatureRegistration (feature));
}
public void registerClientTag (@Nonnull String tag) {
if (AssetRegistry.registerClientTag(tag)) {
(AssetRegistry.getClientTags());
Universe.get().broadcastPacketNoCache(packet);
}
}
}
com/hypixel/hytale/server/core/task/TaskRegistration.java
package com.hypixel.hytale.server.core.task;
import com.hypixel.hytale.registry.Registration;
import java.util.concurrent.Future;
import java.util.function.BooleanSupplier;
import javax.annotation.Nonnull;
public class TaskRegistration extends Registration {
private final Future<?> task;
public TaskRegistration (@Nonnull Future<?> task) {
super (() -> true , () -> task.cancel(false ));
this .task = task;
}
public TaskRegistration (@Nonnull TaskRegistration registration, BooleanSupplier isEnabled, Runnable unregister) {
super (isEnabled, unregister);
this .task = registration.task;
}
public Future<?> getTask() {
return this .task;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .task);
return "TaskRegistration{task=" + var10000 + ", " + super .toString() + "}" ;
}
}
com/hypixel/hytale/server/core/task/TaskRegistry.java
package com.hypixel.hytale.server.core.task;
import com.hypixel.hytale.function.consumer.BooleanConsumer;
import com.hypixel.hytale.registry.Registry;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledFuture;
import java.util.function.BooleanSupplier;
import javax.annotation.Nonnull;
public class TaskRegistry extends Registry <TaskRegistration> {
public TaskRegistry (@Nonnull List<BooleanConsumer> registrations, BooleanSupplier precondition, String preconditionMessage) {
super (registrations, precondition, preconditionMessage, TaskRegistration::new );
}
public TaskRegistration registerTask (@Nonnull CompletableFuture<Void> task) {
return (TaskRegistration)this .register(new TaskRegistration (task));
}
public TaskRegistration registerTask (@Nonnull ScheduledFuture<Void> task) {
return (TaskRegistration)this .register(new TaskRegistration (task));
}
}
com/hypixel/hytale/server/core/ui/Anchor.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
public class Anchor {
public static final BuilderCodec<Anchor> CODEC;
private Value<Integer> left;
private Value<Integer> right;
private Value<Integer> top;
private Value<Integer> bottom;
private Value<Integer> height;
private Value<Integer> full;
private Value<Integer> horizontal;
private Value<Integer> vertical;
private Value<Integer> width;
private Value<Integer> minWidth;
private Value<Integer> maxWidth;
public Anchor () {
}
public void setLeft (Value<Integer> left) {
this .left = left;
}
public void setRight (Value<Integer> right) {
this .right = right;
}
public void setTop (Value<Integer> top) {
this .top = top;
}
public void setBottom (Value<Integer> bottom) {
this .bottom = bottom;
}
{
.height = height;
}
{
.full = full;
}
{
.horizontal = horizontal;
}
{
.vertical = vertical;
}
{
.width = width;
}
{
.minWidth = minWidth;
}
{
.maxWidth = maxWidth;
}
{
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(Anchor.class, Anchor:: ).addField( ( , ValueCodec.INTEGER), (p, t) -> p.left = t, (p) -> p.left)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.right = t, (p) -> p.right)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.top = t, (p) -> p.top)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.bottom = t, (p) -> p.bottom)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.height = t, (p) -> p.height)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.full = t, (p) -> p.full)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.horizontal = t, (p) -> p.horizontal)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.vertical = t, (p) -> p.vertical)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.width = t, (p) -> p.width)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.minWidth = t, (p) -> p.minWidth)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.maxWidth = t, (p) -> p.maxWidth)).build();
}
}
com/hypixel/hytale/server/core/ui/Area.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
public class Area {
public static final BuilderCodec<Area> CODEC;
private int x;
private int y;
private int width;
private int height;
public Area () {
}
@Nonnull
public Area setX (int x) {
this .x = x;
return this ;
}
@Nonnull
public Area setY (int y) {
this .y = y;
return this ;
}
@Nonnull
public Area setWidth (int width) {
this .width = width;
return this ;
}
@Nonnull
public Area {
.height = height;
;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Area.class, Area:: ).addField( ( , Codec.INTEGER), (p, t) -> p.x = t, (p) -> p.x)).addField( ( , Codec.INTEGER), (p, t) -> p.y = t, (p) -> p.y)).addField( ( , Codec.INTEGER), (p, t) -> p.width = t, (p) -> p.width)).addField( ( , Codec.INTEGER), (p, t) -> p.height = t, (p) -> p.height)).build();
}
}
com/hypixel/hytale/server/core/ui/DropdownEntryInfo.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
public class DropdownEntryInfo {
public static final BuilderCodec<DropdownEntryInfo> CODEC;
private LocalizableString label;
private String value;
public DropdownEntryInfo (LocalizableString label, String value) {
this .label = label;
this .value = value;
}
private DropdownEntryInfo () {
}
static {
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(DropdownEntryInfo.class, DropdownEntryInfo::new ).addField(new KeyedCodec ("Label" , LocalizableString.CODEC), (p, t) -> p.label = t, (p) -> p.label)).addField(new KeyedCodec ("Value" , Codec.STRING), (p, t) -> p.value = t, (p) -> p.value)).build();
}
}
com/hypixel/hytale/server/core/ui/ItemGridSlot.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import javax.annotation.Nonnull;
public class ItemGridSlot {
public static final BuilderCodec<ItemGridSlot> CODEC;
private ItemStack itemStack;
private Value<PatchStyle> background;
private Value<PatchStyle> overlay;
private Value<PatchStyle> icon;
private boolean isItemIncompatible;
private String name;
private String description;
private boolean skipItemQualityBackground;
private boolean isActivatable;
private boolean isItemUncraftable;
public ItemGridSlot () {
}
public ItemGridSlot (ItemStack itemStack) {
this .itemStack = itemStack;
}
@Nonnull
public ItemGridSlot setItemStack (ItemStack itemStack) {
this .itemStack = itemStack;
return this ;
}
@Nonnull
public ItemGridSlot {
.background = background;
;
}
ItemGridSlot {
.overlay = overlay;
;
}
ItemGridSlot {
.icon = icon;
;
}
ItemGridSlot {
.isItemIncompatible = itemIncompatible;
;
}
ItemGridSlot {
.name = name;
;
}
ItemGridSlot {
.description = description;
;
}
{
.isItemUncraftable;
}
{
.isItemUncraftable = itemUncraftable;
}
{
.isActivatable;
}
{
.isActivatable = activatable;
}
{
.skipItemQualityBackground;
}
{
.skipItemQualityBackground = skipItemQualityBackground;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ItemGridSlot.class, ItemGridSlot:: ).addField( ( , ItemStack.CODEC), (p, t) -> p.itemStack = t, (p) -> p.itemStack)).addField( ( , ValueCodec.PATCH_STYLE), (p, t) -> p.background = t, (p) -> p.background)).addField( ( , ValueCodec.PATCH_STYLE), (p, t) -> p.overlay = t, (p) -> p.overlay)).addField( ( , ValueCodec.PATCH_STYLE), (p, t) -> p.icon = t, (p) -> p.icon)).addField( ( , Codec.BOOLEAN), (p, t) -> p.isItemIncompatible = t, (p) -> p.isItemIncompatible)).addField( ( , Codec.STRING), (p, t) -> p.name = t, (p) -> p.name)).addField( ( , Codec.STRING), (p, t) -> p.description = t, (p) -> p.description)).addField( ( , Codec.BOOLEAN), (p, t) -> p.skipItemQualityBackground = t, (p) -> p.skipItemQualityBackground)).addField( ( , Codec.BOOLEAN), (p, t) -> p.isActivatable = t, (p) -> p.isActivatable)).addField( ( , Codec.BOOLEAN), (p, t) -> p.isItemUncraftable = t, (p) -> p.isItemUncraftable)).build();
}
}
com/hypixel/hytale/server/core/ui/LocalizableString.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.Schema;
import com.hypixel.hytale.codec.schema.config.StringSchema;
import java.util.Map;
import javax.annotation.Nonnull;
import org.bson.BsonString;
import org.bson.BsonValue;
public class LocalizableString {
public static final LocalizableStringCodec CODEC = new LocalizableStringCodec ();
public static final BuilderCodec<LocalizableString> MESSAGE_OBJECT_CODEC;
private String stringValue;
private String messageId;
private Map<String, String> messageParams;
public LocalizableString () {
}
@Nonnull
public static LocalizableString fromString (String str) {
LocalizableString instance = ();
instance.stringValue = str;
instance;
}
LocalizableString {
fromMessageId(messageId, (Map) );
}
LocalizableString {
();
instance.messageId = messageId;
instance.messageParams = params;
instance;
}
{
MESSAGE_OBJECT_CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(LocalizableString.class, LocalizableString:: ).addField( ( , Codec.STRING), (p, t) -> p.messageId = t, (p) -> p.messageId)).addField( ( , MapCodec.STRING_HASH_MAP_CODEC), (p, t) -> p.messageParams = t, (p) -> p.messageParams)).build();
}
<LocalizableString> {
{
}
LocalizableString {
bsonValue BsonString ? LocalizableString.fromString(bsonValue.asString().getValue()) : (LocalizableString)LocalizableString.MESSAGE_OBJECT_CODEC.decode(bsonValue, extraInfo);
}
BsonValue {
(BsonValue)(t.stringValue != ? (t.stringValue) : LocalizableString.MESSAGE_OBJECT_CODEC.encode(t, extraInfo));
}
Schema {
Schema.anyOf( (), LocalizableString.MESSAGE_OBJECT_CODEC.toSchema(context));
}
}
}
com/hypixel/hytale/server/core/ui/PatchStyle.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
public class PatchStyle {
public static final BuilderCodec<PatchStyle> CODEC;
private Value<String> texturePath;
private Value<Integer> border;
private Value<Integer> horizontalBorder;
private Value<Integer> verticalBorder;
private Value<String> color;
private Value<Area> area;
public PatchStyle () {
}
public PatchStyle (Value<String> texturePath) {
this .texturePath = texturePath;
}
public PatchStyle (Value<String> texturePath, Value<Integer> border) {
this .texturePath = texturePath;
this .border = border;
}
@Nonnull
public PatchStyle setTexturePath (Value<String> texturePath) {
this .texturePath = texturePath;
return this ;
}
@Nonnull
public PatchStyle setBorder (Value<Integer> border) {
this .border = border;
return ;
}
PatchStyle {
.horizontalBorder = horizontalBorder;
;
}
PatchStyle {
.verticalBorder = verticalBorder;
;
}
PatchStyle {
.color = color;
;
}
PatchStyle {
.area = area;
;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(PatchStyle.class, PatchStyle:: ).addField( ( , ValueCodec.STRING), (p, t) -> p.texturePath = t, (p) -> p.texturePath)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.border = t, (p) -> p.border)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.horizontalBorder = t, (p) -> p.horizontalBorder)).addField( ( , ValueCodec.INTEGER), (p, t) -> p.verticalBorder = t, (p) -> p.verticalBorder)).addField( ( , ValueCodec.STRING), (p, t) -> p.color = t, (p) -> p.color)).addField( ( , (Area.CODEC)), (p, t) -> p.area = t, (p) -> p.area)).build();
}
}
com/hypixel/hytale/server/core/ui/Value.java
package com.hypixel.hytale.server.core.ui;
import javax.annotation.Nonnull;
public class Value <T> {
private T value;
private String documentPath;
private String valueName;
private Value (String documentPath, String valueName) {
this .documentPath = documentPath;
this .valueName = valueName;
}
private Value (T value) {
this .value = value;
}
public T getValue () {
return this .value;
}
public String getDocumentPath () {
return this .documentPath;
}
public String getValueName () {
return this .valueName;
}
@Nonnull
public static <T> Value<T> ref (String document, String value) {
return new Value <T>(document, value);
}
@Nonnull
public static <T> Value<T> of (T value) {
<T>(value);
}
}
com/hypixel/hytale/server/core/ui/ValueCodec.java
package com.hypixel.hytale.server.core.ui;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.schema.config.Schema;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.BsonValue;
public class ValueCodec <T> implements Codec <Value<T>> {
public static final ValueCodec<Object> REFERENCE_ONLY = new ValueCodec <Object>((Codec)null );
public static final ValueCodec<String> STRING;
public static final ValueCodec<LocalizableString> LOCALIZABLE_STRING;
public static final ValueCodec<Integer> INTEGER;
public static final ValueCodec<PatchStyle> PATCH_STYLE;
protected Codec<T> codec;
ValueCodec(Codec<T> codec) {
this .codec = codec;
}
public Value<T> decode (BsonValue bsonValue, ExtraInfo extraInfo) {
throw new UnsupportedOperationException ();
}
public BsonValue encode {
(BsonValue)(r.getValue() != ? .codec.encode(r.getValue(), extraInfo) : ( ()).append( , (r.getDocumentPath())).append( , (r.getValueName())));
}
Schema {
.codec.toSchema(context);
}
{
STRING = <String>(Codec.STRING);
LOCALIZABLE_STRING = <LocalizableString>(LocalizableString.CODEC);
INTEGER = <Integer>(Codec.INTEGER);
PATCH_STYLE = <PatchStyle>(PatchStyle.CODEC);
}
}
com/hypixel/hytale/server/core/ui/browser/FileBrowserConfig.java
package com.hypixel.hytale.server.core.ui.browser;
import com.hypixel.hytale.server.core.ui.LocalizableString;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public record FileBrowserConfig (@Nonnull String listElementId, @Nullable String rootSelectorId, @Nullable String searchInputId, @Nullable String currentPathId, @Nonnull List<RootEntry> roots, @Nonnull Set<String> allowedExtensions, boolean enableRootSelector, boolean enableSearch, boolean enableDirectoryNav, boolean enableMultiSelect, int maxResults, @Nullable FileListProvider customProvider) {
public static Builder builder () {
return new Builder ();
}
public static record RootEntry (@Nonnull LocalizableString displayName, @Nonnull Path path) {
public RootEntry (@Nonnull String displayName, @Nonnull Path path) {
this (LocalizableString.fromString(displayName), path);
}
}
public static class Builder {
private String listElementId ;
;
;
;
List<RootEntry> roots = List.of();
Set<String> allowedExtensions = Set.of();
;
;
;
;
;
;
{
}
Builder {
.listElementId = listElementId;
;
}
Builder {
.rootSelectorId = rootSelectorId;
;
}
Builder {
.searchInputId = searchInputId;
;
}
Builder {
.currentPathId = currentPathId;
;
}
Builder {
.roots = roots;
;
}
Builder {
.allowedExtensions = Set.of(extensions);
;
}
Builder {
.allowedExtensions = extensions;
;
}
Builder {
.enableRootSelector = enable;
;
}
Builder {
.enableSearch = enable;
;
}
Builder {
.enableDirectoryNav = enable;
;
}
Builder {
.enableMultiSelect = enable;
;
}
Builder {
.maxResults = maxResults;
;
}
Builder {
.customProvider = provider;
;
}
FileBrowserConfig {
( .listElementId, .rootSelectorId, .searchInputId, .currentPathId, .roots, .allowedExtensions, .enableRootSelector, .enableSearch, .enableDirectoryNav, .enableMultiSelect, .maxResults, .customProvider);
}
}
}
com/hypixel/hytale/server/core/ui/browser/FileBrowserEventData.java
package com.hypixel.hytale.server.core.ui.browser;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nullable;
public class FileBrowserEventData {
public static final String KEY_FILE = "File" ;
public static final String KEY_ROOT = "@Root" ;
public static final String KEY_SEARCH_QUERY = "@SearchQuery" ;
public static final String KEY_SEARCH_RESULT = "SearchResult" ;
public static final String KEY_BROWSE = "Browse" ;
public static final BuilderCodec<FileBrowserEventData> CODEC;
@Nullable
private String file;
@Nullable
String root;
String searchQuery;
String searchResult;
Boolean browse;
{
}
String {
.file;
}
String {
.root;
}
String {
.searchQuery;
}
String {
.searchResult;
}
{
.browse != && .browse;
}
FileBrowserEventData {
();
data.file = file;
data;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(FileBrowserEventData.class, FileBrowserEventData:: ).addField( ( , Codec.STRING), (entry, s) -> entry.file = s, (entry) -> entry.file)).addField( ( , Codec.STRING), (entry, s) -> entry.root = s, (entry) -> entry.root)).addField( ( , Codec.STRING), (entry, s) -> entry.searchQuery = s, (entry) -> entry.searchQuery)).addField( ( , Codec.STRING), (entry, s) -> entry.searchResult = s, (entry) -> entry.searchResult)).addField( ( , Codec.STRING), (entry, s) -> entry.browse = .equalsIgnoreCase(s), (entry) -> entry.browse != && entry.browse ? : )).build();
}
}
com/hypixel/hytale/server/core/ui/browser/FileListProvider.java
package com.hypixel.hytale.server.core.ui.browser;
import java.nio.file.Path;
import java.util.List;
import javax.annotation.Nonnull;
@FunctionalInterface
public interface FileListProvider {
@Nonnull
List<FileEntry> getFiles (@Nonnull Path var1, @Nonnull String var2) ;
public static record FileEntry (@Nonnull String name, @Nonnull String displayName, boolean isDirectory, int matchScore) {
public FileEntry (@Nonnull String name, boolean isDirectory) {
this (name, name, isDirectory, 0 );
}
public FileEntry (@Nonnull String name, @Nonnull String displayName, boolean isDirectory) {
this (name, displayName, isDirectory, 0 );
}
}
}
com/hypixel/hytale/server/core/ui/browser/ServerFileBrowser.java
package com.hypixel.hytale.server.core.ui.browser;
import com.hypixel.hytale.common.util.PathUtil;
import com.hypixel.hytale.common.util.StringCompareUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType;
import com.hypixel.hytale.server.core.ui.DropdownEntryInfo;
import com.hypixel.hytale.server.core.ui.Value;
import com.hypixel.hytale.server.core.ui.builder.EventData;
import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder;
import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public {
HytaleLogger.forEnclosingClass();
Value<String> BUTTON_HIGHLIGHTED = Value.<String>ref( , );
FileBrowserConfig config;
Path root;
Path currentDir;
String searchQuery;
Set<String> selectedItems;
{
.config = config;
.selectedItems = ();
.searchQuery = ;
(!config.roots().isEmpty()) {
.root = ((FileBrowserConfig.RootEntry)config.roots().get( )).path();
} {
.root = Paths.get( );
}
.currentDir = .root.getFileSystem().getPath( );
}
{
(config);
(initialRoot != && Files.isDirectory(initialRoot, [ ])) {
.root = initialRoot;
.currentDir = .root.getFileSystem().getPath( );
}
(initialDir != ) {
.currentDir = initialDir;
}
}
{
( .config.enableRootSelector() && .config.rootSelectorId() != ) {
ObjectArrayList<DropdownEntryInfo> entries = <DropdownEntryInfo>();
(FileBrowserConfig.RootEntry rootEntry : .config.roots()) {
entries.add( (rootEntry.displayName(), rootEntry.path().toString()));
}
commandBuilder.set( .config.rootSelectorId() + , entries);
commandBuilder.set( .config.rootSelectorId() + , .root.toString());
eventBuilder.addEventBinding(CustomUIEventBindingType.ValueChanged, .config.rootSelectorId(), ( ()).append( , .config.rootSelectorId() + ), );
} {
( .config.rootSelectorId() != ) {
commandBuilder.set( .config.rootSelectorId() + , );
}
}
}
{
( .config.enableSearch() && .config.searchInputId() != ) {
(! .searchQuery.isEmpty()) {
commandBuilder.set( .config.searchInputId() + , .searchQuery);
}
eventBuilder.addEventBinding(CustomUIEventBindingType.ValueChanged, .config.searchInputId(), EventData.of( , .config.searchInputId() + ), );
}
}
{
( .config.currentPathId() != ) {
.root.toString().replace( , );
.currentDir.toString().isEmpty() ? : + .currentDir.toString().replace( , );
rootDisplay + relativeDisplay;
commandBuilder.set( .config.currentPathId() + , displayPath);
}
}
{
commandBuilder.clear( .config.listElementId());
List<FileListProvider.FileEntry> entries;
( .config.customProvider() != ) {
entries = .config.customProvider().getFiles( .currentDir, .searchQuery);
} (! .searchQuery.isEmpty() && .config.enableSearch()) {
entries = .buildSearchResults();
} {
entries = .buildDirectoryListing();
}
;
( .config.enableDirectoryNav() && ! .currentDir.toString().isEmpty() && .searchQuery.isEmpty()) {
commandBuilder.append( .config.listElementId(), );
commandBuilder.set( .config.listElementId() + , );
eventBuilder.addEventBinding(CustomUIEventBindingType.Activating, .config.listElementId() + , EventData.of( , ));
++buttonIndex;
}
(FileListProvider.FileEntry entry : entries) {
entry.isDirectory() ? entry.displayName() + : entry.displayName();
commandBuilder.append( .config.listElementId(), );
commandBuilder.set( .config.listElementId() + + buttonIndex + , displayText);
(!entry.isDirectory()) {
commandBuilder.set( .config.listElementId() + + buttonIndex + , BUTTON_HIGHLIGHTED);
}
! .searchQuery.isEmpty() && !entry.isDirectory() ? : ;
eventBuilder.addEventBinding(CustomUIEventBindingType.Activating, .config.listElementId() + + buttonIndex + , EventData.of(eventKey, entry.name()));
++buttonIndex;
}
}
{
.buildRootSelector(commandBuilder, eventBuilder);
.buildSearchInput(commandBuilder, eventBuilder);
.buildCurrentPath(commandBuilder);
.buildFileList(commandBuilder, eventBuilder);
}
{
(data.getSearchQuery() != ) {
.searchQuery = data.getSearchQuery().trim().toLowerCase();
;
} (data.getRoot() != ) {
.findConfigRoot(data.getRoot());
(newRoot == ) {
newRoot = Path.of(data.getRoot());
}
.setRoot(newRoot);
.currentDir = .root.getFileSystem().getPath( );
.searchQuery = ;
;
} (data.getFile() != ) {
data.getFile();
( .equals(fileName)) {
.navigateUp();
;
} {
( .config.enableDirectoryNav()) {
.root.resolve( .currentDir.toString()).resolve(fileName);
(Files.isDirectory(targetPath, [ ])) {
.currentDir = PathUtil.relativize( .root, targetPath);
;
}
}
;
}
} {
data.getSearchResult() != ? : ;
}
}
List<FileListProvider.FileEntry> buildDirectoryListing() {
List<FileListProvider.FileEntry> entries = <FileListProvider.FileEntry>();
.root.resolve( .currentDir.toString());
(!Files.isDirectory(path, [ ])) {
entries;
} {
{
DirectoryStream<Path> stream = Files.newDirectoryStream(path);
{
(Path file : stream) {
file.getFileName().toString();
(!fileName.startsWith( )) {
Files.isDirectory(file, [ ]);
(isDirectory || .matchesExtension(fileName)) {
entries.add( .FileEntry(fileName, isDirectory));
}
}
}
} (Throwable var9) {
(stream != ) {
{
stream.close();
} (Throwable var8) {
var9.addSuppressed(var8);
}
}
var9;
}
(stream != ) {
stream.close();
}
} (IOException e) {
((HytaleLogger.Api)((HytaleLogger.Api)LOGGER.atSevere()).withCause(e)).log( , path);
}
entries.sort((a, b) -> {
(a.isDirectory() == b.isDirectory()) {
a.name().compareToIgnoreCase(b.name());
} {
a.isDirectory() ? - : ;
}
});
entries;
}
}
List<FileListProvider.FileEntry> buildSearchResults() {
List<Path> allFiles = <Path>();
(!Files.isDirectory( .root, [ ])) {
List.of();
} {
{
Files.walkFileTree( .root, <Path>() {
FileVisitResult {
file.getFileName().toString();
(ServerFileBrowser. .matchesExtension(fileName)) {
allFiles.add(file);
}
FileVisitResult.CONTINUE;
}
});
} (IOException e) {
((HytaleLogger.Api)((HytaleLogger.Api)LOGGER.atSevere()).withCause(e)).log( , .root);
}
Object2IntMap<Path> matchScores = <Path>(allFiles.size());
(Path file : allFiles) {
file.getFileName().toString();
.removeExtensions(fileName);
StringCompareUtil.getFuzzyDistance(baseName, .searchQuery, Locale.ENGLISH);
(score > ) {
matchScores.put(file, score);
}
}
matchScores.keySet().stream();
Objects.requireNonNull(matchScores);
(List)var10000.sorted(Comparator.comparingInt(matchScores::getInt).reversed()).limit(( ) .config.maxResults()).map((filex) -> {
PathUtil.relativize( .root, filex);
filex.getFileName().toString();
.removeExtensions(fileName);
.FileEntry(relativePath.toString(), displayName, , matchScores.getInt(filex));
}).collect(Collectors.toList());
}
}
{
( .config.allowedExtensions().isEmpty()) {
;
} {
(String ext : .config.allowedExtensions()) {
(fileName.endsWith(ext)) {
;
}
}
;
}
}
String {
(String ext : .config.allowedExtensions()) {
(fileName.endsWith(ext)) {
fileName.substring( , fileName.length() - ext.length());
}
}
fileName;
}
Path {
.root;
}
{
(Files.isDirectory(root, [ ])) {
.root = root;
}
}
Path {
.currentDir;
}
{
.currentDir = currentDir;
}
String {
.searchQuery;
}
{
.searchQuery = searchQuery;
}
{
(! .currentDir.toString().isEmpty()) {
.currentDir.getParent();
.currentDir = parent != ? parent : Paths.get( );
}
}
{
.root.resolve( .currentDir.toString()).resolve(relativePath.toString());
(targetPath.normalize().startsWith( .root.normalize())) {
(Files.isDirectory(targetPath, [ ])) {
.currentDir = PathUtil.relativize( .root, targetPath);
}
}
}
Set<String> {
Collections.unmodifiableSet( .selectedItems);
}
{
( .config.enableMultiSelect()) {
.selectedItems.add(item);
} {
.selectedItems.clear();
.selectedItems.add(item);
}
}
{
.selectedItems.clear();
}
FileBrowserConfig {
.config;
}
Path {
.root.resolve(relativePath);
!resolved.normalize().startsWith( .root.normalize()) ? : resolved;
}
Path {
.root.resolve( .currentDir.toString()).resolve(fileName);
!resolved.normalize().startsWith( .root.normalize()) ? : resolved;
}
Path {
(FileBrowserConfig.RootEntry rootEntry : .config.roots()) {
(rootEntry.path().toString().equals(pathStr)) {
rootEntry.path();
}
}
;
}
}
com/hypixel/hytale/server/core/ui/builder/EventData.java
package com.hypixel.hytale.server.core.ui.builder;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
public record EventData (Map<String, String> events) {
public EventData () {
this (new Object2ObjectOpenHashMap ());
}
@Nonnull
public EventData append (String key, String value) {
return this .put(key, value);
}
@Nonnull
public <T extends Enum <T>> EventData append (String key, @Nonnull T enumValue) {
return this .put(key, enumValue.name());
}
@Nonnull
public EventData put (String key, String value) {
this .events.put(key, value);
return this ;
}
@Nonnull
public static EventData of (@Nonnull String key, @Nonnull String value) {
HashMap<String, String> map = new ();
map.put(key, value);
(map);
}
}
com/hypixel/hytale/server/core/ui/builder/UICommandBuilder.java
package com.hypixel.hytale.server.core.ui.builder;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.EmptyExtraInfo;
import com.hypixel.hytale.protocol.packets.interface_.CustomUICommand;
import com.hypixel.hytale.protocol.packets.interface_.CustomUICommandType;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import com.hypixel.hytale.server.core.ui.Anchor;
import com.hypixel.hytale.server.core.ui.Area;
import com.hypixel.hytale.server.core.ui.DropdownEntryInfo;
import com.hypixel.hytale.server.core.ui.ItemGridSlot;
import com.hypixel.hytale.server.core.ui.LocalizableString;
import com.hypixel.hytale.server.core.ui.PatchStyle;
import com.hypixel.hytale.server.core.ui.Value;
import com.hypixel.hytale.server.core.ui.ValueCodec;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import org.bson.BsonArray;
import org.bson.BsonBoolean;
import org.bson.BsonDocument;
import org.bson.BsonDouble;
import org.bson.BsonInt32;
import org.bson.BsonNull;
import org.bson.BsonString;
import org.bson.BsonValue;
public class UICommandBuilder {
private static final Map<Class, Codec> CODEC_MAP = new <Class, Codec>();
CustomUICommand[] EMPTY_COMMAND_ARRAY = [ ];
List<CustomUICommand> commands = <CustomUICommand>();
{
}
UICommandBuilder {
.commands.add( (CustomUICommandType.Clear, selector, (String) , (String) ));
;
}
UICommandBuilder {
.commands.add( (CustomUICommandType.Remove, selector, (String) , (String) ));
;
}
UICommandBuilder {
.commands.add( (CustomUICommandType.Append, (String) , (String) , documentPath));
;
}
UICommandBuilder {
.commands.add( (CustomUICommandType.Append, selector, (String) , documentPath));
;
}
UICommandBuilder {
.commands.add( (CustomUICommandType.AppendInline, selector, (String) , document));
;
}
UICommandBuilder {
.commands.add( (CustomUICommandType.InsertBefore, selector, (String) , documentPath));
;
}
UICommandBuilder {
.commands.add( (CustomUICommandType.InsertBeforeInline, selector, (String) , document));
;
}
UICommandBuilder {
();
valueWrapper.put( , bsonValue);
.commands.add( (CustomUICommandType.Set, selector, valueWrapper.toJson(), (String) ));
;
}
<T> UICommandBuilder {
(ref.getValue() != ) {
( );
} {
.setBsonValue(selector, ValueCodec.REFERENCE_ONLY.encode(ref));
}
}
UICommandBuilder {
.setBsonValue(selector, BsonNull.VALUE);
}
UICommandBuilder {
.setBsonValue(selector, (str));
}
UICommandBuilder {
.setBsonValue(selector, Message.CODEC.encode(message, EmptyExtraInfo.EMPTY));
}
UICommandBuilder {
.setBsonValue(selector, (b));
}
UICommandBuilder {
.setBsonValue(selector, (( )n));
}
UICommandBuilder {
.setBsonValue(selector, (n));
}
UICommandBuilder {
.setBsonValue(selector, (n));
}
UICommandBuilder {
(Codec)CODEC_MAP.get(data.getClass());
(codec == ) {
(data.getClass().getName() + );
} {
.setBsonValue(selector, codec.encode(data));
}
}
<T> UICommandBuilder {
(Codec)CODEC_MAP.get(data.getClass().getComponentType());
(codec == ) {
(data.getClass().getName() + );
} {
();
(T d : data) {
arr.add(codec.encode(d));
}
.setBsonValue(selector, arr);
}
}
<T> UICommandBuilder {
Codec<T> codec = ;
();
(T d : data) {
(codec == ) {
codec = (Codec)CODEC_MAP.get(d.getClass());
(codec == ) {
(data.getClass().getName() + );
}
}
arr.add(codec.encode(d));
}
.setBsonValue(selector, arr);
}
CustomUICommand[] getCommands() {
(CustomUICommand[]) .commands.toArray((x$ ) -> [x$ ]);
}
{
CODEC_MAP.put(Area.class, Area.CODEC);
CODEC_MAP.put(ItemGridSlot.class, ItemGridSlot.CODEC);
CODEC_MAP.put(ItemStack.class, ItemStack.CODEC);
CODEC_MAP.put(LocalizableString.class, LocalizableString.CODEC);
CODEC_MAP.put(PatchStyle.class, PatchStyle.CODEC);
CODEC_MAP.put(DropdownEntryInfo.class, DropdownEntryInfo.CODEC);
CODEC_MAP.put(Anchor.class, Anchor.CODEC);
}
}
com/hypixel/hytale/server/core/ui/builder/UIEventBuilder.java
package com.hypixel.hytale.server.core.ui.builder;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBinding;
import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class UIEventBuilder {
public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
public static final CustomUIEventBinding[] EMPTY_EVENT_BINDING_ARRAY = new CustomUIEventBinding [0 ];
@Nonnull
private final List<CustomUIEventBinding> events = new ObjectArrayList <CustomUIEventBinding>();
public UIEventBuilder () {
}
@Nonnull
public UIEventBuilder addEventBinding (CustomUIEventBindingType type, String selector) {
return this .addEventBinding(type, selector, (EventData)null );
}
@Nonnull
UIEventBuilder {
.addEventBinding(type, selector, (EventData) , locksInterface);
}
UIEventBuilder {
.addEventBinding(type, selector, data, );
}
UIEventBuilder {
;
(data != ) {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
dataString = MapCodec.STRING_HASH_MAP_CODEC.encode(data.events(), extraInfo).asDocument().toJson();
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
}
.events.add( (type, selector, dataString, locksInterface));
;
}
CustomUIEventBinding[] getEvents() {
(CustomUIEventBinding[]) .events.toArray((x$ ) -> [x$ ]);
}
}