13
0
geforkt von Mirrors/Velocity
Dieser Commit ist enthalten in:
Five (Xer) 2020-06-07 00:51:21 +02:00
Ursprung 3ed5e7718c
Commit 4e5f708bed
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F306B10E6330E7
2 geänderte Dateien mit 17 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -1,8 +1,8 @@
package com.velocitypowered.proxy.connection.registry; package com.velocitypowered.proxy.connection.registry;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.kyori.nbt.CompoundTag; import net.kyori.nbt.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class DimensionData { public final class DimensionData {
private final String registryIdentifier; private final String registryIdentifier;
@ -12,8 +12,8 @@ public final class DimensionData {
private final boolean isUltrawarm; private final boolean isUltrawarm;
private final boolean hasCeiling; private final boolean hasCeiling;
private final boolean hasSkylight; private final boolean hasSkylight;
private final Optional<Long> fixedTime; private final @Nullable Long fixedTime;
private final Optional<Boolean> hasEnderdragonFight; private final @Nullable Boolean hasEnderdragonFight;
/** /**
* Initializes a new {@link DimensionData} instance. * Initializes a new {@link DimensionData} instance.
@ -30,7 +30,7 @@ public final class DimensionData {
public DimensionData(String registryIdentifier, boolean isNatural, public DimensionData(String registryIdentifier, boolean isNatural,
float ambientLight, boolean isShrunk, boolean isUltrawarm, float ambientLight, boolean isShrunk, boolean isUltrawarm,
boolean hasCeiling, boolean hasSkylight, boolean hasCeiling, boolean hasSkylight,
Optional<Long> fixedTime, Optional<Boolean> hasEnderdragonFight) { @Nullable Long fixedTime, @Nullable Boolean hasEnderdragonFight) {
Preconditions.checkNotNull( Preconditions.checkNotNull(
registryIdentifier, "registryIdentifier cannot be null"); registryIdentifier, "registryIdentifier cannot be null");
Preconditions.checkArgument(registryIdentifier.length() > 0 && !registryIdentifier.isBlank(), Preconditions.checkArgument(registryIdentifier.length() > 0 && !registryIdentifier.isBlank(),
@ -42,10 +42,8 @@ public final class DimensionData {
this.isUltrawarm = isUltrawarm; this.isUltrawarm = isUltrawarm;
this.hasCeiling = hasCeiling; this.hasCeiling = hasCeiling;
this.hasSkylight = hasSkylight; this.hasSkylight = hasSkylight;
this.fixedTime = Preconditions.checkNotNull( this.fixedTime = fixedTime;
fixedTime, "fixedTime optional object cannot be null"); this.hasEnderdragonFight = hasEnderdragonFight;
this.hasEnderdragonFight = Preconditions.checkNotNull(
hasEnderdragonFight, "hasEnderdragonFight optional object cannot be null");
} }
public String getRegistryIdentifier() { public String getRegistryIdentifier() {
@ -76,11 +74,11 @@ public final class DimensionData {
return hasSkylight; return hasSkylight;
} }
public Optional<Long> getFixedTime() { public @Nullable Long getFixedTime() {
return fixedTime; return fixedTime;
} }
public Optional<Boolean> getHasEnderdragonFight() { public @Nullable Boolean getHasEnderdragonFight() {
return hasEnderdragonFight; return hasEnderdragonFight;
} }
@ -99,12 +97,10 @@ public final class DimensionData {
boolean isUltrawarm = values.getBoolean("ultrawarm"); boolean isUltrawarm = values.getBoolean("ultrawarm");
boolean hasCeiling = values.getBoolean("has_ceiling"); boolean hasCeiling = values.getBoolean("has_ceiling");
boolean hasSkylight = values.getBoolean("has_skylight"); boolean hasSkylight = values.getBoolean("has_skylight");
Optional<Long> fixedTime = Optional.fromNullable( Long fixedTime = values.contains("fixed_time")
values.contains("fixed_time") ? values.getLong("fixed_time") : null;
? values.getLong("fixed_time") : null); Boolean hasEnderdragonFight = values.contains("has_enderdragon_fight")
Optional<Boolean> hasEnderdragonFight = Optional.fromNullable( ? values.getBoolean("has_enderdragon_fight") : null;
values.contains("has_enderdragon_fight")
? values.getBoolean("has_enderdragon_fight") : null);
return new DimensionData( return new DimensionData(
registryIdentifier, isNatural, ambientLight, isShrunk, registryIdentifier, isNatural, ambientLight, isShrunk,
isUltrawarm, hasCeiling, hasSkylight, fixedTime, hasEnderdragonFight); isUltrawarm, hasCeiling, hasSkylight, fixedTime, hasEnderdragonFight);
@ -124,11 +120,11 @@ public final class DimensionData {
values.putBoolean("ultrawarm", isUltrawarm); values.putBoolean("ultrawarm", isUltrawarm);
values.putBoolean("has_ceiling", hasCeiling); values.putBoolean("has_ceiling", hasCeiling);
values.putBoolean("has_skylight", hasSkylight); values.putBoolean("has_skylight", hasSkylight);
if (fixedTime.isPresent()) { if (fixedTime != null) {
values.putLong("fixed_time", fixedTime.get()); values.putLong("fixed_time", fixedTime);
} }
if (hasEnderdragonFight.isPresent()) { if (hasEnderdragonFight != null) {
values.putBoolean("has_enderdragon_fight", hasEnderdragonFight.get()); values.putBoolean("has_enderdragon_fight", hasEnderdragonFight);
} }
ret.put("element", values); ret.put("element", values);
return ret; return ret;

Datei anzeigen

@ -59,7 +59,7 @@ public final class DimensionRegistry {
* @return game dimension data or null if not registered * @return game dimension data or null if not registered
*/ */
public @Nullable DimensionData getDimensionData(String dimensionIdentifier) { public @Nullable DimensionData getDimensionData(String dimensionIdentifier) {
return registeredDimensions.getOrDefault(dimensionIdentifier, null); return registeredDimensions.get(dimensionIdentifier);
} }
/** /**