ObjectiveAsset class
Пакет: com.hypixel.hytale.builtin.adventure.objectives.config
Файл: com/hypixel/hytale/builtin/adventure/objectives/config/ObjectiveAsset.java
implements: JsonAssetWithMap<String, DefaultAssetMap<String, ObjectiveAsset>>
Поля (1)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
ASSET_STORE |
Методы (18)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(TaskSet var4 : this.taskSets) |
|
|
for for(TaskSet var4 : this.taskSets) |
static |
DefaultAssetMap<String, ObjectiveAsset> |
getAssetMapDefaultAssetMap<String, ObjectiveAsset> getAssetMap() |
static |
AssetStore<String, ObjectiveAsset, DefaultAssetMap<String, ObjectiveAsset>> |
getAssetStoreAssetStore<String, ObjectiveAsset, DefaultAssetMap<String, ObjectiveAsset>> getAssetStore() |
public |
String |
getCategoryString getCategory() |
public |
ObjectiveCompletionAsset[] |
getCompletionHandlersObjectiveCompletionAsset[] getCompletionHandlers() |
public |
String |
getDescriptionKeyString getDescriptionKey() |
public |
String |
getIdString getId() |
public |
String |
getObjectiveDescriptionKeyString getObjectiveDescriptionKey() |
public |
String |
getObjectiveTitleKeyString getObjectiveTitleKey() |
public |
TaskSet[] |
getTaskSetsTaskSet[] getTaskSets() |
public |
String |
getTitleKeyString getTitleKey() |
|
|
if if(var0.objectiveTitleKey == null) |
|
|
if if(var0.objectiveDescriptionKey == null) |
|
|
if if(ASSET_STORE == null) |
public |
boolean |
isRemoveOnItemDropboolean isRemoveOnItemDrop() |
public |
boolean |
isValidForMarkerboolean isValidForMarker() |
public |
boolean |
isValidForPlayerboolean isValidForPlayer() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.adventure.objectives.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.map.DefaultAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.ObjectivePlugin;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.config.completion.ObjectiveCompletionAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.config.task.ObjectiveTaskAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.config.task.TaskSet;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.schema.metadata.ui.UIEditor;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import java.text.MessageFormat;
class="kw">import java.util.Arrays;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">public class ObjectiveAsset class="kw">implements JsonAssetWithMap<String, DefaultAssetMap<String, ObjectiveAsset>> {
@Nonnull
class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, ObjectiveAsset> CODEC = AssetBuilderCodec.builder(
ObjectiveAsset.class,
ObjectiveAsset::new,
Codec.STRING,
(var0, var1) -> var0.id = var1,
var0 -> var0.id,
(var0, var1) -> var0.extraData = var1,
var0 -> var0.extraData
)
.appendInherited(
new KeyedCodec<>("Category", Codec.STRING), (var0, var1) -> var0.category = var1, var0 -> var0.category, (var0, var1) -> var0.category = var1.category
)
.add()
.<TaskSet[]>appendInherited(
new KeyedCodec<>("TaskSets", new ArrayCodec<>(TaskSet.CODEC, TaskSet[]::new)),
(var0, var1) -> var0.taskSets = var1,
var0 -> var0.taskSets,
(var0, var1) -> var0.taskSets = var1.taskSets
)
.addValidator(Validators.nonEmptyArray())
.add()
.appendInherited(
new KeyedCodec<>("Completions", new ArrayCodec<>(ObjectiveCompletionAsset.CODEC, ObjectiveCompletionAsset[]::new)),
(var0, var1) -> var0.completionHandlers = var1,
var0 -> var0.completionHandlers,
(var0, var1) -> var0.completionHandlers = var1.completionHandlers
)
.add()
.<String>appendInherited(
new KeyedCodec<>("TitleId", Codec.STRING),
(var0, var1) -> var0.objectiveTitleKey = var1,
var0 -> var0.objectiveTitleKey,
(var0, var1) -> var0.objectiveTitleKey = var1.objectiveTitleKey
)
.metadata(new UIEditor(new UIEditor.LocalizationKeyField("server.objectives.{assetId}.title", true)))
.add()
.<String>appendInherited(
new KeyedCodec<>("DescriptionId", Codec.STRING),
(var0, var1) -> var0.objectiveDescriptionKey = var1,
var0 -> var0.objectiveDescriptionKey,
(var0, var1) -> var0.objectiveDescriptionKey = var1.objectiveDescriptionKey
)
.metadata(new UIEditor(new UIEditor.LocalizationKeyField("server.objectives.{assetId}.desc")))
.add()
.appendInherited(
new KeyedCodec<>("RemoveOnItemDrop", Codec.BOOLEAN),
(var0, var1) -> var0.removeOnItemDrop = var1,
var0 -> var0.removeOnItemDrop,
(var0, var1) -> var0.removeOnItemDrop = var1.removeOnItemDrop
)
.add()
.afterDecode(var0 -> {
if (var0.objectiveTitleKey == null) {
var0.objectiveTitleKey = MessageFormat.format("server.objectives.{0}.title", var0.id);
}
if (var0.objectiveDescriptionKey == null) {
var0.objectiveDescriptionKey = MessageFormat.format("server.objectives.{0}.desc", var0.id);
}
})
.build();
@Nonnull
class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(ObjectiveAsset::getAssetStore));
class="kw">private class="kw">static AssetStore<String, ObjectiveAsset, DefaultAssetMap<String, ObjectiveAsset>> ASSET_STORE;
class="kw">protected AssetExtraInfo.Data extraData;
class="kw">protected String id;
class="kw">protected String category;
class="kw">protected TaskSet[] taskSets;
class="kw">protected ObjectiveCompletionAsset[] completionHandlers;
class="kw">protected String objectiveTitleKey;
class="kw">protected String objectiveDescriptionKey;
class="kw">protected boolean removeOnItemDrop;
class="kw">public class="kw">static AssetStore<String, ObjectiveAsset, DefaultAssetMap<String, ObjectiveAsset>> getAssetStore() {
if (ASSET_STORE == null) {
ASSET_STORE = AssetRegistry.getAssetStore(ObjectiveAsset.class);
}
class="kw">return ASSET_STORE;
}
class="kw">public class="kw">static DefaultAssetMap<String, ObjectiveAsset> getAssetMap() {
class="kw">return (DefaultAssetMap<String, ObjectiveAsset>)getAssetStore().getAssetMap();
}
class="kw">public ObjectiveAsset(String var1, String var2, TaskSet[] var3, ObjectiveCompletionAsset[] var4, String var5, String var6, boolean var7) {
this.id = var1;
this.category = var2;
this.taskSets = var3;
this.completionHandlers = var4;
this.objectiveTitleKey = var5;
this.objectiveDescriptionKey = var6;
this.removeOnItemDrop = var7;
}
class="kw">protected ObjectiveAsset() {
}
class="kw">public String getId() {
class="kw">return this.id;
}
class="kw">public String getCategory() {
class="kw">return this.category;
}
class="kw">public String getTitleKey() {
class="kw">return this.objectiveTitleKey;
}
class="kw">public String getDescriptionKey() {
class="kw">return this.objectiveDescriptionKey;
}
class="kw">public TaskSet[] getTaskSets() {
class="kw">return this.taskSets;
}
class="kw">public ObjectiveCompletionAsset[] getCompletionHandlers() {
class="kw">return this.completionHandlers;
}
class="kw">public String getObjectiveTitleKey() {
class="kw">return this.objectiveTitleKey;
}
class="kw">public String getObjectiveDescriptionKey() {
class="kw">return this.objectiveDescriptionKey;
}
class="kw">public boolean isRemoveOnItemDrop() {
class="kw">return this.removeOnItemDrop;
}
class="kw">public boolean isValidForPlayer() {
for (TaskSet var4 : this.taskSets) {
for (ObjectiveTaskAsset var8 : var4.getTasks()) {
if (!var8.getTaskScope().isTaskPossibleForPlayer()) {
ObjectivePlugin.get().getLogger().at(Level.WARNING).log("Task %s isn't valid for Player held objective", var8.getClass().toString());
class="kw">return false;
}
}
}
class="kw">return true;
}
class="kw">public boolean isValidForMarker() {
for (TaskSet var4 : this.taskSets) {
for (ObjectiveTaskAsset var8 : var4.getTasks()) {
if (!var8.getTaskScope().isTaskPossibleForMarker()) {
ObjectivePlugin.get().getLogger().at(Level.WARNING).log("Task %s isn't valid for Marker held objective", var8.getClass().toString());
class="kw">return false;
}
}
}
class="kw">return true;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "ObjectiveAsset{id='"
+ this.id
+ "', category='"
+ this.category
+ "', taskSets="
+ Arrays.toString(this.taskSets)
+ ", completionHandlers="
+ Arrays.toString(this.completionHandlers)
+ ", objectiveTitleKey='"
+ this.objectiveTitleKey
+ "', objectiveDescriptionKey='"
+ this.objectiveDescriptionKey
+ "', removeOnItemDrop="
+ this.removeOnItemDrop
+ "}";
}
}