SetGameFlagInteraction class
Пакет: com.hypixel.hytale.builtin.gameflags
Файл: com/hypixel/hytale/builtin/gameflags/SetGameFlagInteraction.java
extends: SimpleInstantInteraction
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<SetGameFlagInteraction> |
CODEC |
|
GameFlagsResource |
var4 |
Методы (1)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(this.raise) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.gameflags;
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.validation.Validators;
class="kw">import com.hypixel.hytale.protocol.InteractionState;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.WaitForDataFrom;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction;
class="kw">import javax.annotation.Nonnull;
class="kw">public class SetGameFlagInteraction class="kw">extends SimpleInstantInteraction {
class="kw">public class="kw">static class="kw">final BuilderCodec<SetGameFlagInteraction> CODEC = BuilderCodec.builder(
SetGameFlagInteraction.class, SetGameFlagInteraction::new, SimpleInstantInteraction.CODEC
)
.documentation("An interaction that writes the given game flag.")
.<String>appendInherited(new KeyedCodec<>("Key", Codec.STRING), (var0, var1) -> var0.key = var1, var0 -> var0.key, (var0, var1) -> var0.key = var1.key)
.addValidator(Validators.nonNull())
.add()
.appendInherited(new KeyedCodec<>("Value", Codec.INTEGER), (var0, var1) -> var0.value = var1, var0 -> var0.value, (var0, var1) -> var0.value = var1.value)
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("Raise", Codec.BOOLEAN), (var0, var1) -> var0.raise = var1, var0 -> var0.raise, (var0, var1) -> var0.raise = var1.raise
)
.documentation("Whether to only ever raise the flag instead of overwriting it.")
.add()
.build();
class="kw">private String key;
class="kw">private int value = 1;
class="kw">private boolean raise = false;
class="kw">public SetGameFlagInteraction() {
}
@Override
class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
GameFlagsResource var4 = GameFlagsResource.get();
if (this.raise) {
var4.raise(this.key, this.value);
} else {
var4.set(this.key, this.value);
}
GameFlagsResource.flush();
var2.getState().state = InteractionState.Finished;
}
@Nonnull
@Override
class="kw">public WaitForDataFrom getWaitForDataFrom() {
class="kw">return WaitForDataFrom.Server;
}
}