ResettingWorldTask .java

com.mojang.realmsclient.util.task.ResettingWorldTask (class): members: sendResetRequest, serverId, getTitle, callback, title, run, LOGGER. imports: Logger.

com.mojang.realmsclient.util.taskclass69 linescommonextends LongRunningTask1.6 KB

API Surface (3)

void sendResetRequest(final RealmsClient client, final long serverId)
void run()
Component getTitle()

Fields & Constants (4)

LOGGER
serverId
title
callback

String literals (1)

"Couldn't reset world"

Code Graph: Dependencies (5)

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

Full Source

ResettingWorldTask.java69 lines · Minecraft 26.3 · verbatim
1
package com.mojang.realmsclient.util.task;
2
3
import com.mojang.logging.LogUtils;
4
import com.mojang.realmsclient.client.RealmsClient;
5
import com.mojang.realmsclient.exception.RealmsServiceException;
6
import com.mojang.realmsclient.exception.RetryCallException;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import net.minecraft.network.chat.Component;
10
import org.slf4j.Logger;
11
12
@Environment(EnvType.CLIENT)
13
public abstract class ResettingWorldTask extends LongRunningTask {
14
	private static final Logger LOGGER = LogUtils.getLogger();
15
	private final long serverId;
16
	private final Component title;
17
	private final Runnable callback;
18
19
	public ResettingWorldTask(final long serverId, final Component title, final Runnable callback) {
20
		this.serverId = serverId;
21
		this.title = title;
22
		this.callback = callback;
23
	}
24
25
	protected abstract void sendResetRequest(final RealmsClient client, final long serverId) throws RealmsServiceException;
26
27
	@Override
28
	public void run() {
29
		RealmsClient client = RealmsClient.getOrCreate();
30
		int i = 0;
31
32
		while (i < 25) {
33
			try {
34
				if (this.aborted()) {
35
					return;
36
				}
37
38
				this.sendResetRequest(client, this.serverId);
39
				if (this.aborted()) {
40
					return;
41
				}
42
43
				this.callback.run();
44
				return;
45
			} catch (RetryCallException e) {
46
				if (this.aborted()) {
47
					return;
48
				}
49
50
				pause(e.delaySeconds);
51
				i++;
52
			} catch (Exception e) {
53
				if (this.aborted()) {
54
					return;
55
				}
56
57
				LOGGER.error("Couldn't reset world");
58
				this.error(e);
59
				return;
60
			}
61
		}
62
	}
63
64
	@Override
65
	public Component getTitle() {
66
		return this.title;
67
	}
68
}
69

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