RealmsSlot .java

com.mojang.realmsclient.dto.RealmsSlot (class, 54 lines): members: RealmsWorldOptionsJsonAdapter, defaults, slotId, isHardcore, settings, options, copy.

com.mojang.realmsclient.dtoclass54 linescommon1.8 KB

Implements

API Surface (5)

RealmsSlot defaults(final int slotId)
RealmsSlot copy()
boolean isHardcore()
void write(final JsonWriter jsonWriter, final RealmsWorldOptions realmsSlotOptions)
RealmsWorldOptions read(final JsonReader jsonReader)

Fields & Constants (3)

slotId
options
settings

String literals (3)

"slotId"
"options"
"settings"

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RealmsSlot.java54 lines · Minecraft 26.3 · verbatim
1
package com.mojang.realmsclient.dto;
2
3
import com.google.gson.TypeAdapter;
4
import com.google.gson.annotations.JsonAdapter;
5
import com.google.gson.annotations.SerializedName;
6
import com.google.gson.stream.JsonReader;
7
import com.google.gson.stream.JsonWriter;
8
import java.io.IOException;
9
import java.util.ArrayList;
10
import java.util.List;
11
import net.fabricmc.api.EnvType;
12
import net.fabricmc.api.Environment;
13
14
@Environment(EnvType.CLIENT)
15
public final class RealmsSlot implements ReflectionBasedSerialization {
16
	@SerializedName("slotId")
17
	public int slotId;
18
	@SerializedName("options")
19
	@JsonAdapter(RealmsSlot.RealmsWorldOptionsJsonAdapter.class)
20
	public RealmsWorldOptions options;
21
	@SerializedName("settings")
22
	public List<RealmsSetting> settings;
23
24
	public RealmsSlot(final int slotId, final RealmsWorldOptions options, final List<RealmsSetting> settings) {
25
		this.slotId = slotId;
26
		this.options = options;
27
		this.settings = settings;
28
	}
29
30
	public static RealmsSlot defaults(final int slotId) {
31
		return new RealmsSlot(slotId, RealmsWorldOptions.createEmptyDefaults(), List.of(RealmsSetting.hardcoreSetting(false)));
32
	}
33
34
	public RealmsSlot copy() {
35
		return new RealmsSlot(this.slotId, this.options.copy(), new ArrayList<>(this.settings));
36
	}
37
38
	public boolean isHardcore() {
39
		return RealmsSetting.isHardcore(this.settings);
40
	}
41
42
	@Environment(EnvType.CLIENT)
43
	private static class RealmsWorldOptionsJsonAdapter extends TypeAdapter<RealmsWorldOptions> {
44
		public void write(final JsonWriter jsonWriter, final RealmsWorldOptions realmsSlotOptions) throws IOException {
45
			jsonWriter.jsonValue(new GuardedSerializer().toJson(realmsSlotOptions));
46
		}
47
48
		public RealmsWorldOptions read(final JsonReader jsonReader) throws IOException {
49
			String json = jsonReader.nextString();
50
			return RealmsWorldOptions.parse(new GuardedSerializer(), json);
51
		}
52
	}
53
}
54

Decompiled Minecraft 26.3 source of RealmsSlot (com/mojang/realmsclient/dto/RealmsSlot.java) with Mojang official mappings, stored verbatim on the site.