SoundSet class
Пакет: com.hypixel.hytale.server.core.asset.type.soundset.config
Файл: com/hypixel/hytale/server/core/asset/type/soundset/config/SoundSet.java
implements: JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, SoundSet>>,
NetworkSerializable<com.hypixel.hytale.protocol.SoundSet>
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
ASSET_STORE |
final |
int |
EMPTY_ID |
|
com.hypixel.hytale.protocol.SoundSet |
var1 |
|
com.hypixel.hytale.protocol.SoundSet |
var2 |
Методы (8)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
IndexedLookupTableAssetMap<String, SoundSet> |
getAssetMapIndexedLookupTableAssetMap<String, SoundSet> getAssetMap() |
static |
AssetStore<String, SoundSet, IndexedLookupTableAssetMap<String, SoundSet>> |
getAssetStoreAssetStore<String, SoundSet, IndexedLookupTableAssetMap<String, SoundSet>> getAssetStore() |
public |
String |
getIdString getId() |
public |
Map<String, String> |
getSoundEventIdsMap<String, String> getSoundEventIds() |
public |
Object2IntMap<String> |
getSoundEventIndicesObject2IntMap<String> getSoundEventIndices() |
|
|
if if(ASSET_STORE == null) |
|
|
if if(var1 != null) |
protected |
void |
processConfigvoid processConfig() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.soundset.config;
class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetKeyValidator;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.assetstore.AssetStore;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.codec.ContainedAssetCodec;
class="kw">import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.MapCodec;
class="kw">import com.hypixel.hytale.codec.schema.metadata.ui.UIDefaultCollapsedState;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import it.unimi.dsi.fastutil.objects.Object2IntMap;
class="kw">import it.unimi.dsi.fastutil.objects.Object2IntMaps;
class="kw">import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
class="kw">import java.lang.ref.SoftReference;
class="kw">import java.util.Collections;
class="kw">import java.util.Map;
class="kw">import java.util.Map.Entry;
class="kw">import javax.annotation.Nonnull;
class="kw">public class SoundSet
class="kw">implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, SoundSet>>,
NetworkSerializable<com.hypixel.hytale.protocol.SoundSet> {
class="kw">public class="kw">static class="kw">final int EMPTY_ID = 0;
class="kw">public class="kw">static class="kw">final String EMPTY = "EMPTY";
class="kw">public class="kw">static class="kw">final SoundSet EMPTY_SOUND_SET = new SoundSet("EMPTY");
class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, SoundSet> CODEC = AssetBuilderCodec.builder(
SoundSet.class, SoundSet::new, Codec.STRING, (var0, var1) -> var0.id = var1, var0 -> var0.id, (var0, var1) -> var0.data = var1, var0 -> var0.data
)
.appendInherited(
new KeyedCodec<>("SoundEvents", MapCodec.STRING_HASH_MAP_CODEC),
(var0, var1) -> var0.soundEventIds = var1,
var0 -> var0.soundEventIds,
(var0, var1) -> var0.soundEventIds = var1.soundEventIds
)
.addValidator(Validators.nonNull())
.addValidator(SoundEvent.VALIDATOR_CACHE.getMapValueValidator())
.metadata(UIDefaultCollapsedState.UNCOLLAPSED)
.add()
.<SoundCategory>appendInherited(
new KeyedCodec<>("Category", new EnumCodec<>(SoundCategory.class)),
(var0, var1) -> var0.category = var1,
var0 -> var0.category,
(var0, var1) -> var0.category = var1.category
)
.addValidator(Validators.nonNull())
.add()
.afterDecode(SoundSet::processConfig)
.build();
class="kw">public class="kw">static class="kw">final Codec<String> CHILD_ASSET_CODEC = new ContainedAssetCodec<>(SoundSet.class, CODEC);
class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(SoundSet::getAssetStore));
class="kw">private class="kw">static AssetStore<String, SoundSet, IndexedLookupTableAssetMap<String, SoundSet>> ASSET_STORE;
class="kw">protected AssetExtraInfo.Data data;
class="kw">protected String id;
class="kw">protected Map<String, String> soundEventIds = Collections.emptyMap();
class="kw">protected class="kw">transient Object2IntMap<String> soundEventIndices = Object2IntMaps.emptyMap();
@Nonnull
class="kw">protected SoundCategory category = SoundCategory.SFX;
class="kw">private SoftReference<com.hypixel.hytale.protocol.SoundSet> cachedPacket;
class="kw">public class="kw">static AssetStore<String, SoundSet, IndexedLookupTableAssetMap<String, SoundSet>> getAssetStore() {
if (ASSET_STORE == null) {
ASSET_STORE = AssetRegistry.getAssetStore(SoundSet.class);
}
class="kw">return ASSET_STORE;
}
class="kw">public class="kw">static IndexedLookupTableAssetMap<String, SoundSet> getAssetMap() {
class="kw">return (IndexedLookupTableAssetMap<String, SoundSet>)getAssetStore().getAssetMap();
}
class="kw">public SoundSet(String var1, Map<String, String> var2, SoundCategory var3) {
this.id = var1;
this.soundEventIds = var2;
this.category = var3;
}
class="kw">public SoundSet(String var1) {
this.id = var1;
}
class="kw">protected SoundSet() {
}
class="kw">public String getId() {
class="kw">return this.id;
}
class="kw">public Map<String, String> getSoundEventIds() {
class="kw">return this.soundEventIds;
}
class="kw">public Object2IntMap<String> getSoundEventIndices() {
class="kw">return this.soundEventIndices;
}
class="kw">protected void processConfig() {
if (!this.soundEventIds.isEmpty()) {
this.soundEventIndices = new Object2IntOpenHashMap();
for (Entry var2 : this.soundEventIds.entrySet()) {
this.soundEventIndices.put(var2.getKey(), SoundEvent.getAssetMap().getIndex(var2.getValue()));
}
}
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "SoundSet{id='"
+ this.id
+ "', soundEventIds="
+ this.soundEventIds
+ ", soundEventIndices="
+ this.soundEventIndices
+ ", category="
+ this.category
+ "}";
}
@Nonnull
class="kw">public com.hypixel.hytale.protocol.SoundSet toPacket() {
com.hypixel.hytale.protocol.SoundSet var1 = this.cachedPacket == null ? null : this.cachedPacket.get();
if (var1 != null) {
class="kw">return var1;
}
com.hypixel.hytale.protocol.SoundSet var2 = new com.hypixel.hytale.protocol.SoundSet();
var2.id = this.id;
var2.sounds = this.soundEventIndices;
var2.category = this.category;
this.cachedPacket = new SoftReference<>(var2);
class="kw">return var2;
}
}