RegionSelectionPreference.java

com.mojang.realmsclient.dto.RegionSelectionPreference

信息

  • 全限定名:com.mojang.realmsclient.dto.RegionSelectionPreference
  • 类型:public enum
  • 包:com.mojang.realmsclient.dto
  • 源码路径:src/main/java/com/mojang/realmsclient/dto/RegionSelectionPreference.java
  • 起始行号:L13
  • 职责:

    TODO

字段/常量

  • AUTOMATIC_PLAYER, AUTOMATIC_OWNER, MANUAL

    • 类型: RegionSelectionPreference
    • 修饰符: package-private
    • 源码定位: L14
    • 说明:

      TODO

  • DEFAULT_SELECTION

    • 类型: RegionSelectionPreference
    • 修饰符: public static final
    • 源码定位: L18
    • 说明:

      TODO

  • id

    • 类型: int
    • 修饰符: public final
    • 源码定位: L19
    • 说明:

      TODO

  • translationKey

    • 类型: String
    • 修饰符: public final
    • 源码定位: L20
    • 说明:

      TODO

内部类/嵌套类型

  • com.mojang.realmsclient.dto.RegionSelectionPreference.RegionSelectionPreferenceJsonAdapter
    • 类型: class
    • 修饰符: public static
    • 源码定位: L28
    • 说明:

      TODO

构造器

private RegionSelectionPreference(int id, String translationKey) @ L22

  • 构造器名:RegionSelectionPreference
  • 源码定位:L22
  • 修饰符:private

参数:

  • id: int
  • translationKey: String

说明:

TODO

方法

下面的方法块按源码顺序生成。

代码

@OnlyIn(Dist.CLIENT)
public enum RegionSelectionPreference {
    AUTOMATIC_PLAYER(0, "realms.configuration.region_preference.automatic_player"),
    AUTOMATIC_OWNER(1, "realms.configuration.region_preference.automatic_owner"),
    MANUAL(2, "");
 
    public static final RegionSelectionPreference DEFAULT_SELECTION = AUTOMATIC_PLAYER;
    public final int id;
    public final String translationKey;
 
    private RegionSelectionPreference(int id, String translationKey) {
        this.id = id;
        this.translationKey = translationKey;
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class RegionSelectionPreferenceJsonAdapter extends TypeAdapter<RegionSelectionPreference> {
        private static final Logger LOGGER = LogUtils.getLogger();
 
        public void write(JsonWriter jsonWriter, RegionSelectionPreference regionSelectionPreference) throws IOException {
            jsonWriter.value((long)regionSelectionPreference.id);
        }
 
        public RegionSelectionPreference read(JsonReader jsonReader) throws IOException {
            int id = jsonReader.nextInt();
 
            for (RegionSelectionPreference value : RegionSelectionPreference.values()) {
                if (value.id == id) {
                    return value;
                }
            }
 
            LOGGER.warn("Unsupported RegionSelectionPreference {}", id);
            return RegionSelectionPreference.DEFAULT_SELECTION;
        }
    }
}

引用的其他类