IncrementCooldownInteraction class
Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config.client
Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/IncrementCooldownInteraction.java
extends: SimpleInstantInteraction
Поля (5)
| Модификаторы | Тип | Имя |
|---|---|---|
|
com.hypixel.hytale.protocol.IncrementCooldownInteraction |
var2 |
|
CooldownHandler.Cooldown |
var3 |
|
String |
var4 |
|
|
var4 |
|
InteractionCooldown |
var5 |
Методы (6)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(var5 != null) |
|
|
if if(var3 != null) |
|
|
if if(this.cooldownTime != 0.0F) |
|
|
if if(this.charge != 0) |
|
|
if if(this.chargeTime != 0.0F) |
protected |
void |
processCooldownvoid processCooldown(@Nonnull CooldownHandler var1, @Nonnull String var2) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.interaction.config.client;
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.protocol.Interaction;
class="kw">import com.hypixel.hytale.protocol.InteractionCooldown;
class="kw">import com.hypixel.hytale.protocol.InteractionState;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
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">import javax.annotation.Nullable;
class="kw">public class IncrementCooldownInteraction class="kw">extends SimpleInstantInteraction {
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<IncrementCooldownInteraction> CODEC = BuilderCodec.builder(
IncrementCooldownInteraction.class, IncrementCooldownInteraction::new, SimpleInstantInteraction.CODEC
)
.documentation("Increase the given cooldown.")
.<String>appendInherited(
new KeyedCodec<>("Id", Codec.STRING), (var0, var1) -> var0.cooldown = var1, var0 -> var0.cooldown, (var0, var1) -> var0.cooldown = var1.cooldown
)
.documentation("The ID of the cooldown to increment")
.add()
.<Float>appendInherited(
new KeyedCodec<>("Time", Codec.FLOAT),
(var0, var1) -> var0.cooldownTime = var1,
var0 -> var0.cooldownTime,
(var0, var1) -> var0.cooldownTime = var1.cooldownTime
)
.documentation("The amount of time to increase the current cooldown time by")
.add()
.<Float>appendInherited(
new KeyedCodec<>("ChargeTime", Codec.FLOAT),
(var0, var1) -> var0.chargeTime = var1,
var0 -> var0.chargeTime,
(var0, var1) -> var0.chargeTime = var1.chargeTime
)
.documentation("The amount of time to increase the current charge time by")
.add()
.<Integer>appendInherited(
new KeyedCodec<>("Charge", Codec.INTEGER), (var0, var1) -> var0.charge = var1, var0 -> var0.charge, (var0, var1) -> var0.charge = var1.charge
)
.documentation("The amount of empty charges to recharge")
.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 the recharge of this cooldown should be interrupted")
.add()
.afterDecode(var0 -> var0.chargeTime = -var0.chargeTime)
.build();
@Nullable
class="kw">private String cooldown;
class="kw">private float cooldownTime;
class="kw">private float chargeTime;
class="kw">private int charge;
class="kw">private boolean interruptRecharge;
class="kw">public IncrementCooldownInteraction() {
}
@Override
class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
String var4 = this.cooldown;
if (var4 == null || var4.isEmpty()) {
InteractionCooldown var5 = var2.getChain().getRootInteraction().getCooldown();
if (var5 != null) {
var4 = var5.cooldownId;
}
}
this.processCooldown(var3, var4);
var2.getState().state = InteractionState.Finished;
}
class="kw">protected void processCooldown(@Nonnull CooldownHandler var1, @Nonnull String var2) {
CooldownHandler.Cooldown var3 = var1.getCooldown(var2);
if (var3 != null) {
if (this.cooldownTime != 0.0F) {
var3.increaseTime(this.cooldownTime);
}
if (this.charge != 0) {
var3.replenishCharge(this.charge, this.interruptRecharge);
}
if (this.chargeTime != 0.0F) {
var3.increaseChargeTime(this.chargeTime);
}
}
}
@Nonnull
@Override
class="kw">protected Interaction generatePacket() {
class="kw">return new com.hypixel.hytale.protocol.IncrementCooldownInteraction();
}
@Override
class="kw">protected void configurePacket(Interaction var1) {
super.configurePacket(var1);
com.hypixel.hytale.protocol.IncrementCooldownInteraction var2 = (com.hypixel.hytale.protocol.IncrementCooldownInteraction)var1;
var2.cooldownId = this.cooldown;
var2.cooldownIncrementTime = this.cooldownTime;
var2.cooldownIncrementCharge = this.charge;
var2.cooldownIncrementChargeTime = this.chargeTime;
var2.cooldownIncrementInterrupt = this.interruptRecharge;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "IncrementCooldownInteraction{} " + super.toString();
}
}