SoundEventValidators class

Пакет: com.hypixel.hytale.server.core.asset.type.soundevent.validator

Файл: com/hypixel/hytale/server/core/asset/type/soundevent/validator/SoundEventValidators.java

Поля (8)

МодификаторыТипИмя
final SoundEventValidators.LoopValidator LOOPING
private final int channelCount
private final boolean looping
return
return
assert var1
SoundEvent var3
SoundEvent var3

Методы (11)

МодификаторыВозвратСигнатура
public ChannelValidatorpublic ChannelValidator(int var1)
private LoopValidatorprivate LoopValidator(boolean var1)
public void acceptpublic void accept(@Nullable String var1, @Nonnull ValidationResults var2)
public void acceptpublic void accept(@Nullable String var1, @Nonnull ValidationResults var2)
if if(var1 != null)
if if(var3 == null)
if if(var1 != null)
if if(var3 == null)
if if(this.looping)
public void updateSchemapublic void updateSchema(SchemaContext var1, Schema var2)
public void updateSchemapublic void updateSchema(SchemaContext var1, Schema var2)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.soundevent.validator;

class="kw">import com.hypixel.hytale.codec.schema.SchemaContext;
class="kw">import com.hypixel.hytale.codec.schema.config.Schema;
class="kw">import com.hypixel.hytale.codec.validation.ValidationResults;
class="kw">import com.hypixel.hytale.codec.validation.Validator;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.server.core.asset.common.SoundFileValidators;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEventLayer;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class SoundEventValidators {
   class="kw">public class="kw">static class="kw">final SoundEventValidators.LoopValidator LOOPING = new SoundEventValidators.LoopValidator(true);
   class="kw">public class="kw">static class="kw">final SoundEventValidators.LoopValidator ONESHOT = new SoundEventValidators.LoopValidator(false);
   class="kw">public class="kw">static class="kw">final SoundEventValidators.ChannelValidator MONO = new SoundEventValidators.ChannelValidator(1);
   class="kw">public class="kw">static class="kw">final SoundEventValidators.ChannelValidator STEREO = new SoundEventValidators.ChannelValidator(2);
   class="kw">public class="kw">static class="kw">final ValidatorCache<String> MONO_VALIDATOR_CACHE = new ValidatorCache<>(MONO);
   class="kw">public class="kw">static class="kw">final ValidatorCache<String> STEREO_VALIDATOR_CACHE = new ValidatorCache<>(STEREO);
   class="kw">public class="kw">static class="kw">final ValidatorCache<String> ONESHOT_VALIDATOR_CACHE = new ValidatorCache<>(ONESHOT);

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

   class="kw">public class="kw">static class ChannelValidator class="kw">implements Validator<String> {
      class="kw">private class="kw">final int channelCount;

      class="kw">public ChannelValidator(int var1) {
         assert var1 == 1 || var1 == 2;
         this.channelCount = var1;
      }

      class="kw">public void accept(@Nullable String var1, @Nonnull ValidationResults var2) {
         if (var1 != null) {
            SoundEvent var3 = SoundEvent.getAssetMap().getAsset(var1);
            if (var3 == null) {
               var2.fail("Sound event with name '" + var1 + "' does not exist");
            } else {
               if (var3.getHighestNumberOfChannels() != this.channelCount) {
                  var2.fail(
                     "Sound event with name '"
                        + var1
                        + "' is "
                        + SoundFileValidators.getEncoding(var3.getHighestNumberOfChannels())
                        + " instead of "
                        + SoundFileValidators.getEncoding(this.channelCount)
                  );
               }
            }
         }
      }

      @Override
      class="kw">public void updateSchema(SchemaContext var1, Schema var2) {
      }
   }

   class="kw">public class="kw">static class LoopValidator class="kw">implements Validator<String> {
      class="kw">private class="kw">final boolean looping;

      class="kw">private LoopValidator(boolean var1) {
         this.looping = var1;
      }

      class="kw">public void accept(@Nullable String var1, @Nonnull ValidationResults var2) {
         if (var1 != null) {
            SoundEvent var3 = SoundEvent.getAssetMap().getAsset(var1);
            if (var3 == null) {
               var2.fail("Sound event with name '" + var1 + "' does not exist");
            } else if (var3.getLayers() != null) {
               if (this.looping) {
                  for (SoundEventLayer var7 : var3.getLayers()) {
                     if (var7.isLooping()) {
                        class="kw">return;
                     }
                  }

                  var2.fail("Sound event with name '" + var1 + "' does not have a looping layer");
               } else {
                  for (SoundEventLayer var11 : var3.getLayers()) {
                     if (var11.isLooping()) {
                        var2.fail("Sound event with name '" + var1 + "' has a looping layer and is not a oneshot sound");
                        class="kw">return;
                     }
                  }
               }
            }
         }
      }

      @Override
      class="kw">public void updateSchema(SchemaContext var1, Schema var2) {
      }
   }
}