ModifiedAsset class

Пакет: com.hypixel.hytale.builtin.asseteditor.data

Файл: com/hypixel/hytale/builtin/asseteditor/data/ModifiedAsset.java

Поля (1)

МодификаторыТипИмя
final BuilderCodec<ModifiedAsset> CODEC

Методы (1)

МодификаторыВозвратСигнатура
public void markEditedByvoid markEditedBy(@Nonnull EditorClient var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.asseteditor.data;

class="kw">import com.hypixel.hytale.builtin.asseteditor.EditorClient;
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.EnumCodec;
class="kw">import com.hypixel.hytale.common.util.PathUtil;
class="kw">import com.hypixel.hytale.protocol.packets.asseteditor.AssetInfo;
class="kw">import com.hypixel.hytale.protocol.packets.asseteditor.AssetPath;
class="kw">import java.nio.file.Path;
class="kw">import java.time.Instant;
class="kw">import java.util.UUID;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class ModifiedAsset {
   class="kw">public class="kw">static class="kw">final BuilderCodec<ModifiedAsset> CODEC = BuilderCodec.builder(ModifiedAsset.class, ModifiedAsset::new)
      .append(new KeyedCodec<>("File", Codec.PATH), (var0, var1) -> var0.dataFile = var1, var0 -> var0.dataFile)
      .add()
      .append(new KeyedCodec<>("Path", Codec.PATH), (var0, var1) -> var0.path = var1, var0 -> var0.path)
      .add()
      .append(new KeyedCodec<>("OldPath", Codec.PATH), (var0, var1) -> var0.oldPath = var1, var0 -> var0.oldPath)
      .add()
      .append(new KeyedCodec<>("IsNew", Codec.BOOLEAN), (var0, var1) -> var0.state = var1 ? AssetState.NEW : var0.state, var0 -> null)
      .add()
      .append(new KeyedCodec<>("IsDeleted", Codec.BOOLEAN), (var0, var1) -> var0.state = var1 ? AssetState.DELETED : var0.state, var0 -> null)
      .add()
      .append(new KeyedCodec<>("State", new EnumCodec<>(AssetState.class)), (var0, var1) -> var0.state = var1, var0 -> var0.state)
      .add()
      .append(
         new KeyedCodec<>("LastModificationTimestamp", Codec.INSTANT, true),
         (var0, var1) -> var0.lastModificationTimestamp = var1,
         var0 -> var0.lastModificationTimestamp
      )
      .add()
      .append(
         new KeyedCodec<>("LastModificationPlayerUuid", Codec.UUID_STRING, true),
         (var0, var1) -> var0.lastModificationPlayerUuid = var1,
         var0 -> var0.lastModificationPlayerUuid
      )
      .add()
      .append(
         new KeyedCodec<>("LastModificationUsername", Codec.STRING, true),
         (var0, var1) -> var0.lastModificationUsername = var1,
         var0 -> var0.lastModificationUsername
      )
      .add()
      .build();
   @Nullable
   class="kw">public Path dataFile;
   class="kw">public Path path;
   @Nullable
   class="kw">public Path oldPath;
   class="kw">public AssetState state = AssetState.CHANGED;
   class="kw">public Instant lastModificationTimestamp;
   class="kw">public UUID lastModificationPlayerUuid;
   class="kw">public String lastModificationUsername;

   class="kw">public ModifiedAsset() {
   }

   class="kw">public void markEditedBy(@Nonnull EditorClient var1) {
      this.lastModificationTimestamp = Instant.now();
      this.lastModificationUsername = var1.getUsername();
      this.lastModificationPlayerUuid = var1.getUuid();
   }

   @Nonnull
   class="kw">public AssetInfo toAssetInfoPacket(String var1) {
      class="kw">return new AssetInfo(
         new AssetPath(var1, PathUtil.toUnixPathString(this.path)),
         this.oldPath != null ? new AssetPath(var1, PathUtil.toUnixPathString(this.oldPath)) : null,
         this.state == AssetState.DELETED,
         this.state == AssetState.NEW,
         this.lastModificationTimestamp.toEpochMilli(),
         this.lastModificationUsername
      );
   }
}