RootInteraction class
Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config
Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/RootInteraction.java
implements: JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, RootInteraction>>,
NetworkSerializable<com.hypixel.hytale.protocol.RootInteraction>
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
ASSET_STORE |
|
OperationsBuilder |
var1 |
|
com.hypixel.hytale.protocol.RootInteraction |
var1 |
|
IndexedLookupTableAssetMap |
var1 |
|
boolean |
var2 |
|
int |
var2 |
|
|
var2 |
|
int |
var3 |
|
Interaction |
var7 |
Методы (22)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException(var13 + " needs client data but isn't marked as requiring syncing to remote clients") |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var0) |
public |
void |
buildvoid build(@Nonnull Set<String> var1) |
public |
void |
buildvoid build() |
|
|
for for(String var6 : this.interactionIds) |
|
|
for for(Operation var11 : this.operations) |
|
|
for for(int var2 = 0; var2 < this.interactionIds.length; var2++) |
public |
float |
getClickQueuingTimeoutfloat getClickQueuingTimeout() |
public |
AssetExtraInfo.Data |
getDataAssetExtraInfo.Data getData() |
public |
String |
getIdString getId() |
public |
String[] |
getInteractionIdsString[] getInteractionIds() |
public |
int |
getOperationMaxint getOperationMax() |
|
|
if if(ASSET_STORE == null) |
|
|
if if(this.operations != null) |
|
|
if if(this.interactionIds != null) |
|
|
if if(var7 != null) |
|
|
if if(this.data != null) |
|
|
if if(var0 == null) |
|
|
if if(var2 == Integer.MIN_VALUE) |
|
|
if if(var3 == Integer.MIN_VALUE) |
public |
boolean |
needsRemoteSyncboolean needsRemoteSync() |
public |
boolean |
resetCooldownOnStartboolean resetCooldownOnStart() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.interaction.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.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.EnumMapCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.MapCodec;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.codec.validation.validator.FloatArrayValidator;
class="kw">import com.hypixel.hytale.common.util.ArrayUtil;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.protocol.GameMode;
class="kw">import com.hypixel.hytale.protocol.InteractionCooldown;
class="kw">import com.hypixel.hytale.protocol.RootInteractionSettings;
class="kw">import com.hypixel.hytale.protocol.WaitForDataFrom;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.Operation;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.OperationsBuilder;
class="kw">import java.util.Arrays;
class="kw">import java.util.Collections;
class="kw">import java.util.HashMap;
class="kw">import java.util.List;
class="kw">import java.util.Map;
class="kw">import java.util.Set;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class RootInteraction
class="kw">implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, RootInteraction>>,
NetworkSerializable<com.hypixel.hytale.protocol.RootInteraction> {
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<InteractionCooldown> COOLDOWN_CODEC = BuilderCodec.builder(InteractionCooldown.class, InteractionCooldown::new)
.appendInherited(
new KeyedCodec<>("Id", Codec.STRING),
(var0, var1) -> var0.cooldownId = var1,
var0 -> var0.cooldownId,
(var0, var1) -> var0.cooldownId = var1.cooldownId
)
.documentation("The Id for the cooldown.\n\nCooldowns can be used on different interactions but share a cooldown.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("Cooldown", Codec.FLOAT), (var0, var1) -> var0.cooldown = var1, var0 -> var0.cooldown, (var0, var1) -> var0.cooldown = var1.cooldown
)
.addValidator(Validators.greaterThanOrEqual(0.0F))
.documentation("The time in seconds this cooldown should last for.")
.add()
.<float[]>appendInherited(
new KeyedCodec<>("Charges", Codec.FLOAT_ARRAY),
(var0, var1) -> var0.chargeTimes = var1,
var0 -> var0.chargeTimes,
(var0, var1) -> var0.chargeTimes = var1.chargeTimes
)
.addValidator(new FloatArrayValidator(Validators.greaterThanOrEqual(0.0F)))
.documentation("The charge times available for this interaction.")
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("SkipCooldownReset", Codec.BOOLEAN),
(var0, var1) -> var0.skipCooldownReset = var1,
var0 -> var0.skipCooldownReset,
(var0, var1) -> var0.skipCooldownReset = var1.skipCooldownReset
)
.documentation("Determines whether resetting cooldown should be skipped.")
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("InterruptRecharge", Codec.BOOLEAN),
(var0, var1) -> var0.interruptRecharge = var1,
var0 -> var0.interruptRecharge,
(var0, var1) -> var0.interruptRecharge = var1.interruptRecharge
)
.documentation("Determines whether recharge is interrupted by use.")
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("ClickBypass", Codec.BOOLEAN),
(var0, var1) -> var0.clickBypass = var1,
var0 -> var0.clickBypass,
(var0, var1) -> var0.clickBypass = var1.clickBypass
)
.documentation("Whether this cooldown can be bypassed by clicking.")
.add()
.build();
@Nonnull
class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, RootInteraction> CODEC = AssetBuilderCodec.<String, RootInteraction>builder(
RootInteraction.class,
RootInteraction::new,
Codec.STRING,
(var0, var1) -> var0.id = var1,
var0 -> var0.id,
(var0, var1) -> var0.data = var1,
var0 -> var0.data
)
.documentation(
"A **RootInteraction** serves as an entry point into a set of **Interaction**s.\n\nIn order to start an interaction chain a **RootInteraction** is required.\nA basic **RootInteraction** can simply contain a reference to single interaction within _Interactions_ field which will be the entire chain. More complex cases can configure the other fields.\n\nMost fields configured here apply to all **Interaction**s contained the root and any **Interaction**s they contain as well. Systems that look at tags for interactions may also check the root interaction as well reducing the need to duplicate them on all nested interactions."
)
.<String[]>appendInherited(
new KeyedCodec<>("Interactions", Interaction.CHILD_ASSET_CODEC_ARRAY),
(var0, var1) -> var0.interactionIds = var1,
var0 -> var0.interactionIds,
(var0, var1) -> var0.interactionIds = var1.interactionIds
)
.addValidator(Validators.nonNull())
.addValidator(Validators.nonEmptyArray())
.addValidatorLate(() -> Interaction.VALIDATOR_CACHE.getArrayValidator().late())
.documentation(
"The list of interactions that will be run when starting a chain with this root interaction. Interactions in this list will be run in sequence."
)
.add()
.<InteractionCooldown>appendInherited(
new KeyedCodec<>("Cooldown", COOLDOWN_CODEC),
(var0, var1) -> var0.cooldown = var1,
var0 -> var0.cooldown,
(var0, var1) -> var0.cooldown = var1.cooldown
)
.documentation(
"Cooldowns are used to prevent an interaction from running repeatedly too quickly.\n\nDuring a cooldown attempting to run an interaction with the same cooldown id will fail."
)
.add()
.<InteractionRules>appendInherited(
new KeyedCodec<>("Rules", InteractionRules.CODEC), (var0, var1) -> var0.rules = var1, var0 -> var0.rules, (var0, var1) -> var0.rules = var1.rules
)
.documentation("A set of rules that control when this root interaction can run or what interactions this root being active prevents.")
.addValidator(Validators.nonNull())
.add()
.<Map<GameMode, RootInteractionSettings>>appendInherited(
new KeyedCodec<>(
"Settings",
new EnumMapCodec<>(
GameMode.class,
BuilderCodec.builder(RootInteractionSettings.class, RootInteractionSettings::new)
.appendInherited(
new KeyedCodec<>("Cooldown", COOLDOWN_CODEC),
(var0, var1) -> var0.cooldown = var1,
var0 -> var0.cooldown,
(var0, var1) -> var0.cooldown = var1.cooldown
)
.documentation(
"Cooldowns are used to prevent an interaction from running repeatedly too quickly.\n\nDuring a cooldown attempting to run an interaction with the same cooldown id will fail."
)
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("AllowSkipChainOnClick", Codec.BOOLEAN),
(var0, var1) -> var0.allowSkipChainOnClick = var1,
var0 -> var0.allowSkipChainOnClick,
(var0, var1) -> var0.allowSkipChainOnClick = var1.allowSkipChainOnClick
)
.documentation("Whether to skip the whole interaction chain when another click is sent.")
.add()
.build()
)
),
(var0, var1) -> var0.settings = var1,
var0 -> var0.settings,
(var0, var1) -> var0.settings = var1.settings
)
.documentation("Per a gamemode settings.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("ClickQueuingTimeout", Codec.FLOAT),
(var0, var1) -> var0.clickQueuingTimeout = var1,
var0 -> var0.clickQueuingTimeout,
(var0, var1) -> var0.clickQueuingTimeout = var1.clickQueuingTimeout
)
.documentation("Controls the amount of time this root interaction can remain in the click queue before being discarded.")
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("RequireNewClick", Codec.BOOLEAN),
(var0, var1) -> var0.requireNewClick = var1,
var0 -> var0.requireNewClick,
(var0, var1) -> var0.requireNewClick = var1.requireNewClick
)
.documentation("Requires the user to click again before running another root interaction of the same type.")
.add()
.<String>appendInherited(
new KeyedCodec<>("HudInputBindingEntry", Codec.STRING),
(var0, var1) -> var0.hudInputBindingEntry = var1,
var0 -> var0.hudInputBindingEntry,
(var0, var1) -> var0.hudInputBindingEntry = var1.hudInputBindingEntry
)
.documentation(
"The localization key the client shows as an input binding hint on the HUD for whichever input this root interaction is bound to. When unset, no hint is shown."
)
.add()
.build();
@Nonnull
class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(RootInteraction::getAssetStore));
@Nonnull
class="kw">public class="kw">static class="kw">final ContainedAssetCodec<String, RootInteraction, ?> CHILD_ASSET_CODEC = new ContainedAssetCodec<>(RootInteraction.class, CODEC);
@Nonnull
class="kw">public class="kw">static class="kw">final Codec<String[]> CHILD_ASSET_CODEC_ARRAY = new ArrayCodec<>(CHILD_ASSET_CODEC, String[]::new);
@Nonnull
class="kw">public class="kw">static class="kw">final MapCodec<String, HashMap<String, String>> CHILD_ASSET_CODEC_MAP = new MapCodec<>(CHILD_ASSET_CODEC, HashMap::new);
class="kw">private class="kw">static AssetStore<String, RootInteraction, IndexedLookupTableAssetMap<String, RootInteraction>> ASSET_STORE;
class="kw">protected String id;
class="kw">protected AssetExtraInfo.Data data;
@Nonnull
class="kw">protected String[] interactionIds = ArrayUtil.EMPTY_STRING_ARRAY;
@Nullable
class="kw">protected InteractionCooldown cooldown;
@Nonnull
class="kw">protected Map<GameMode, RootInteractionSettings> settings = Collections.emptyMap();
class="kw">protected boolean requireNewClick;
class="kw">protected float clickQueuingTimeout;
@Nullable
class="kw">protected String hudInputBindingEntry;
@Nonnull
class="kw">protected InteractionRules rules = InteractionRules.DEFAULT_RULES;
class="kw">protected Operation[] operations;
class="kw">protected boolean needsRemoteSync;
class="kw">public RootInteraction() {
}
class="kw">public RootInteraction(@Nonnull String var1, @Nonnull String... var2) {
this.id = var1;
this.interactionIds = var2;
this.data = new AssetExtraInfo.Data(RootInteraction.class, var1, null);
}
class="kw">public RootInteraction(@Nonnull String var1, @Nullable InteractionCooldown var2, @Nonnull String... var3) {
this.id = var1;
this.cooldown = var2;
this.interactionIds = var3;
this.data = new AssetExtraInfo.Data(RootInteraction.class, var1, null);
}
@Nonnull
class="kw">public class="kw">static AssetStore<String, RootInteraction, IndexedLookupTableAssetMap<String, RootInteraction>> getAssetStore() {
if (ASSET_STORE == null) {
ASSET_STORE = AssetRegistry.getAssetStore(RootInteraction.class);
}
class="kw">return ASSET_STORE;
}
@Nonnull
class="kw">public class="kw">static IndexedLookupTableAssetMap<String, RootInteraction> getAssetMap() {
class="kw">return (IndexedLookupTableAssetMap<String, RootInteraction>)getAssetStore().getAssetMap();
}
class="kw">public String getId() {
class="kw">return this.id;
}
class="kw">public boolean needsRemoteSync() {
class="kw">return this.needsRemoteSync;
}
class="kw">public boolean resetCooldownOnStart() {
class="kw">return this.cooldown == null || !this.cooldown.skipCooldownReset;
}
@Nullable
class="kw">public Operation getOperation(int var1) {
class="kw">return var1 >= this.operations.length ? null : this.operations[var1];
}
class="kw">public int getOperationMax() {
class="kw">return this.operations.length;
}
class="kw">public String[] getInteractionIds() {
class="kw">return this.interactionIds;
}
@Nonnull
class="kw">public Map<GameMode, RootInteractionSettings> getSettings() {
class="kw">return this.settings;
}
class="kw">public float getClickQueuingTimeout() {
class="kw">return this.clickQueuingTimeout;
}
@Nullable
class="kw">public String getHudInputBindingEntry() {
class="kw">return this.hudInputBindingEntry;
}
@Nonnull
class="kw">public InteractionRules getRules() {
class="kw">return this.rules;
}
@Nullable
class="kw">public InteractionCooldown getCooldown() {
class="kw">return this.cooldown;
}
class="kw">public AssetExtraInfo.Data getData() {
class="kw">return this.data;
}
class="kw">public void build(@Nonnull Set<String> var1) {
if (this.operations != null) {
this.build();
}
}
class="kw">public void build() {
if (this.interactionIds != null) {
OperationsBuilder var1 = new OperationsBuilder();
boolean var2 = false;
for (String var6 : this.interactionIds) {
Interaction var7 = Interaction.getAssetMap().getAsset(var6);
if (var7 != null) {
var7.compile(var1);
var2 |= var7.needsRemoteSync();
}
}
this.operations = var1.build();
this.needsRemoteSync = var2;
for (Operation var11 : this.operations) {
if (var11.getInnerOperation() class="kw">instanceof Interaction var13 && var13.getWaitForDataFrom() == WaitForDataFrom.Client && !var13.needsRemoteSync()) {
throw new IllegalArgumentException(var13 + " needs client data but isn't marked as requiring syncing to remote clients");
}
}
}
}
@Nonnull
class="kw">public com.hypixel.hytale.protocol.RootInteraction toPacket() {
com.hypixel.hytale.protocol.RootInteraction var1 = new com.hypixel.hytale.protocol.RootInteraction();
var1.id = this.id;
var1.interactions = new int[this.interactionIds.length];
for (int var2 = 0; var2 < this.interactionIds.length; var2++) {
var1.interactions[var2] = Interaction.getInteractionIdOrUnknown(this.interactionIds[var2]);
}
var1.clickQueuingTimeout = this.clickQueuingTimeout;
var1.requireNewClick = this.requireNewClick;
var1.hudInputBindingEntry = this.hudInputBindingEntry;
var1.rules = this.rules.toPacket();
var1.settings = this.settings;
var1.cooldown = this.cooldown;
if (this.data != null) {
var1.tags = this.data.getTags().keySet().toIntArray();
}
class="kw">return var1;
}
@Nullable
@Deprecated
class="kw">public class="kw">static RootInteraction getRootInteractionOrUnknown(@Nonnull String var0) {
class="kw">return getAssetMap().getAsset(getRootInteractionIdOrUnknown(var0));
}
@Deprecated
class="kw">public class="kw">static int getRootInteractionIdOrUnknown(@Nullable String var0) {
if (var0 == null) {
class="kw">return Integer.MIN_VALUE;
}
IndexedLookupTableAssetMap var1 = getAssetMap();
int var2 = var1.getIndex(var0);
if (var2 == Integer.MIN_VALUE) {
HytaleLogger.getLogger().at(Level.WARNING).log("Missing root interaction %s", var0);
getAssetStore().loadAssets("Hytale:Hytale", List.of(new RootInteraction(var0)));
int var3 = var1.getIndex(var0);
if (var3 == Integer.MIN_VALUE) {
throw new IllegalArgumentException("Unknown key! " + var0);
}
var2 = var3;
}
class="kw">return var2;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "RootInteraction{id='"
+ this.id
+ "', interactionIds="
+ Arrays.toString(this.interactionIds)
+ ", settings="
+ this.settings
+ ", requireNewClick="
+ this.requireNewClick
+ ", clickQueuingTimeout="
+ this.clickQueuingTimeout
+ ", hudInputBindingEntry='"
+ this.hudInputBindingEntry
+ "', rules="
+ this.rules
+ ", operations="
+ Arrays.toString(this.operations)
+ ", needsRemoteSync="
+ this.needsRemoteSync
+ "}";
}
}