DiskBanStorageProvider class

Пакет: com.hypixel.hytale.server.core.modules.accesscontrol.provider

Файл: com/hypixel/hytale/server/core/modules/accesscontrol/provider/DiskBanStorageProvider.java

implements: BanStorageProvider

Поля (1)

МодификаторыТипИмя
final String ID

Методы (2)

МодификаторыВозвратСигнатура
abstract return new HytaleBanProviderreturn new HytaleBanProvider(this.path)
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Ban list path must be within a trusted directory: " + this.path)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.accesscontrol.provider;

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.common.util.PathUtil;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;

class="kw">public class DiskBanStorageProvider class="kw">implements BanStorageProvider {
   class="kw">public class="kw">static class="kw">final String ID = "Disk";
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<DiskBanStorageProvider> CODEC = BuilderCodec.builder(DiskBanStorageProvider.class, DiskBanStorageProvider::new)
      .append(new KeyedCodec<>("Path", Codec.STRING), (var0, var1) -> var0.path = Path.of(var1), var0 -> var0.path.toString())
      .add()
      .build();
   @Nonnull
   class="kw">private Path path = Path.of("bans.json");

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

   @Nonnull
   @Override
   class="kw">public BanProvider getBanProvider() {
      if (!PathUtil.isInTrustedRoot(this.path)) {
         throw new IllegalStateException("Ban list path must be within a trusted directory: " + this.path);
      } else {
         class="kw">return new HytaleBanProvider(this.path);
      }
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "DiskBanStorageProvider{path=" + this.path + "}";
   }
}