Skip to content

Commit 245f7e2

Browse files
Fix DummyInitializer unit test to bootstrap without errors (ViaVersion#3965)
1 parent 9d3db4c commit 245f7e2

File tree

3 files changed

+80
-3
lines changed

3 files changed

+80
-3
lines changed

common/src/test/java/com/viaversion/viaversion/common/dummy/DummyInitializer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import com.viaversion.viaversion.ViaManagerImpl;
2121
import com.viaversion.viaversion.api.Via;
22-
import com.viaversion.viaversion.protocol.ProtocolManagerImpl;
2322

2423
public final class DummyInitializer {
2524

@@ -31,7 +30,10 @@ public static void init() {
3130
}
3231

3332
initialized = true;
34-
Via.init(new ViaManagerImpl(new TestPlatform(), null, null, null));
35-
((ProtocolManagerImpl) Via.getManager().getProtocolManager()).registerProtocols();
33+
Via.init(new ViaManagerImpl(new TestPlatform(), new TestInjector(), null, new TestLoader()));
34+
35+
final ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
36+
manager.init();
37+
manager.onServerLoaded();
3638
}
3739
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
3+
* Copyright (C) 2016-2024 ViaVersion and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.viaversion.viaversion.common.dummy;
19+
20+
import com.google.gson.JsonObject;
21+
import com.viaversion.viaversion.api.platform.ViaInjector;
22+
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
23+
24+
public class TestInjector implements ViaInjector {
25+
26+
@Override
27+
public void inject() {
28+
}
29+
30+
@Override
31+
public void uninject() {
32+
33+
}
34+
35+
@Override
36+
public ProtocolVersion getServerProtocolVersion() {
37+
return ProtocolVersion.v1_15_2;
38+
}
39+
40+
@Override
41+
public JsonObject getDump() {
42+
return null;
43+
}
44+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
3+
* Copyright (C) 2016-2024 ViaVersion and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.viaversion.viaversion.common.dummy;
19+
20+
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
21+
22+
public class TestLoader implements ViaPlatformLoader {
23+
24+
@Override
25+
public void load() {
26+
}
27+
28+
@Override
29+
public void unload() {
30+
}
31+
}

0 commit comments

Comments
 (0)