FlockAsset class
Пакет: com.hypixel.hytale.server.flock.config
Файл: com/hypixel/hytale/server/flock/config/FlockAsset.java
implements: JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, FlockAsset>>
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<FlockAsset> |
ABSTRACT_CODEC |
|
|
ASSET_STORE |
Методы (8)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
IndexedLookupTableAssetMap<String, FlockAsset> |
getAssetMapIndexedLookupTableAssetMap<String, FlockAsset> getAssetMap() |
static |
AssetStore<String, FlockAsset, IndexedLookupTableAssetMap<String, FlockAsset>> |
getAssetStoreAssetStore<String, FlockAsset, IndexedLookupTableAssetMap<String, FlockAsset>> getAssetStore() |
public |
String[] |
getBlockedRolesString[] getBlockedRoles() |
public |
String |
getIdString getId() |
public |
int |
getMaxGrowSizeint getMaxGrowSize() |
abstract abstract |
int |
getMinFlockSizeint getMinFlockSize() |
|
|
if if(ASSET_STORE == null) |
abstract abstract |
int |
pickFlockSizeint pickFlockSize() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.flock.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.AssetCodecMapCodec;
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.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.lookup.Priority;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.common.util.ArrayUtil;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">public class="kw">abstract class FlockAsset class="kw">implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, FlockAsset>> {
class="kw">public class="kw">static class="kw">final BuilderCodec<FlockAsset> ABSTRACT_CODEC = BuilderCodec.abstractBuilder(FlockAsset.class)
.documentation("A flock definition.")
.<Integer>appendInherited(
new KeyedCodec<>("MaxGrowSize", Codec.INTEGER),
(var0, var1) -> var0.maxGrowSize = var1,
var0 -> var0.maxGrowSize,
(var0, var1) -> var0.maxGrowSize = var1.maxGrowSize
)
.documentation(
"The maximum size a flock can possibly grow to after spawning. It is technically possible to spawn a flock without specifying a definition (e.g. via a command), in which case the maximum grow size is irrelevant."
)
.addValidator(Validators.greaterThanOrEqual(0))
.add()
.<String[]>appendInherited(
new KeyedCodec<>("BlockedRoles", Codec.STRING_ARRAY),
(var0, var1) -> var0.blockedRoles = var1,
var0 -> var0.blockedRoles,
(var0, var1) -> var0.blockedRoles = var1.blockedRoles
)
.documentation(
"An array of roles that will not be allowed to join this flock once it has been spawned. This is used to exclude roles from the list of allowed roles in the NPC configuration of the initial leader."
)
.addValidator(Validators.uniqueInArray())
.add()
.build();
class="kw">public class="kw">static class="kw">final AssetCodecMapCodec<String, FlockAsset> CODEC = new AssetCodecMapCodec<String, RangeSizeFlockAsset>(
Codec.STRING, (var0, var1) -> var0.id = var1, var0 -> var0.id, (var0, var1) -> var0.data = var1, var0 -> var0.data, true
)
.register(Priority.DEFAULT, "Default", RangeSizeFlockAsset.class, RangeSizeFlockAsset.CODEC);
class="kw">public class="kw">static class="kw">final Codec<String> CHILD_ASSET_CODEC = new ContainedAssetCodec<>(FlockAsset.class, CODEC);
class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(FlockAsset::getAssetStore));
class="kw">private class="kw">static AssetStore<String, FlockAsset, IndexedLookupTableAssetMap<String, FlockAsset>> ASSET_STORE;
class="kw">private AssetExtraInfo.Data data;
class="kw">protected String id;
class="kw">protected int maxGrowSize = 8;
class="kw">protected String[] blockedRoles = ArrayUtil.EMPTY_STRING_ARRAY;
class="kw">public class="kw">static AssetStore<String, FlockAsset, IndexedLookupTableAssetMap<String, FlockAsset>> getAssetStore() {
if (ASSET_STORE == null) {
ASSET_STORE = AssetRegistry.getAssetStore(FlockAsset.class);
}
class="kw">return ASSET_STORE;
}
class="kw">public class="kw">static IndexedLookupTableAssetMap<String, FlockAsset> getAssetMap() {
class="kw">return (IndexedLookupTableAssetMap<String, FlockAsset>)getAssetStore().getAssetMap();
}
class="kw">protected FlockAsset() {
}
class="kw">protected FlockAsset(String var1) {
this.id = var1;
}
class="kw">public String getId() {
class="kw">return this.id;
}
class="kw">public class="kw">abstract int getMinFlockSize();
class="kw">public class="kw">abstract int pickFlockSize();
class="kw">public int getMaxGrowSize() {
class="kw">return this.maxGrowSize;
}
class="kw">public String[] getBlockedRoles() {
class="kw">return this.blockedRoles;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "FlockAsset{id='" + this.id + "', maxGrowSize=" + this.maxGrowSize + ", blockedRoles=" + Arrays.toString(this.blockedRoles) + "}";
}
class="kw">static {
CODEC.register("Weighted", WeightedSizeFlockAsset.class, WeightedSizeFlockAsset.CODEC);
}
}