Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Create builder for ViaManager
Dieser Commit ist enthalten in:
Ursprung
573374866b
Commit
e56bce2f31
2
TODOLIST
2
TODOLIST
@ -1,3 +1 @@
|
|||||||
Handle injector errors
|
Handle injector errors
|
||||||
|
|
||||||
Important: Create builder for ViaManager which allows supplying on the command exectutor, injector, platform :D
|
|
@ -45,8 +45,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
|||||||
public ViaVersionPlugin() {
|
public ViaVersionPlugin() {
|
||||||
// Config magic
|
// Config magic
|
||||||
conf = new ViaConfig(this);
|
conf = new ViaConfig(this);
|
||||||
|
// Command handler
|
||||||
|
commandHandler = new BukkitCommandHandler();
|
||||||
// Init platform
|
// Init platform
|
||||||
Via.init(this);
|
Via.init(ViaManager.builder()
|
||||||
|
.platform(this)
|
||||||
|
.commandHandler(commandHandler)
|
||||||
|
.injector(new BukkitViaInjector())
|
||||||
|
.build());
|
||||||
// For compatibility
|
// For compatibility
|
||||||
ViaVersion.setInstance(this);
|
ViaVersion.setInstance(this);
|
||||||
|
|
||||||
@ -95,7 +101,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
|||||||
Via.getManager().init();
|
Via.getManager().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommand("viaversion").setExecutor(commandHandler = new BukkitCommandHandler());
|
getCommand("viaversion").setExecutor(commandHandler);
|
||||||
getCommand("viaversion").setTabCompleter(commandHandler);
|
getCommand("viaversion").setTabCompleter(commandHandler);
|
||||||
|
|
||||||
// Warn them if they have anti-xray on and they aren't using spigot
|
// Warn them if they have anti-xray on and they aren't using spigot
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package us.myles.ViaVersion;
|
package us.myles.ViaVersion;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -18,9 +19,10 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@Builder
|
||||||
public class ViaManager {
|
public class ViaManager {
|
||||||
private ViaPlatform platform;
|
|
||||||
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
|
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
|
||||||
|
private ViaPlatform platform;
|
||||||
private ViaProviders providers = new ViaProviders();
|
private ViaProviders providers = new ViaProviders();
|
||||||
@Setter
|
@Setter
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
@ -29,10 +31,6 @@ public class ViaManager {
|
|||||||
private ViaCommandHandler commandHandler;
|
private ViaCommandHandler commandHandler;
|
||||||
private ViaPlatformLoader loader;
|
private ViaPlatformLoader loader;
|
||||||
|
|
||||||
public ViaManager(ViaPlatform platform) {
|
|
||||||
this.platform = platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
if (System.getProperty("ViaVersion") != null) {
|
if (System.getProperty("ViaVersion") != null) {
|
||||||
// Reload?
|
// Reload?
|
||||||
|
@ -11,10 +11,11 @@ public class Via {
|
|||||||
@Getter
|
@Getter
|
||||||
private static ViaManager manager;
|
private static ViaManager manager;
|
||||||
|
|
||||||
public static void init(ViaPlatform platform) {
|
public static void init(ViaManager viaManager) {
|
||||||
Validate.isTrue(platform == null, "Platform is already set");
|
Validate.isTrue(manager == null, "ViaManager is already set");
|
||||||
Via.platform = platform;
|
|
||||||
Via.manager = new ViaManager(platform);
|
Via.platform = viaManager.getPlatform();
|
||||||
|
Via.manager = viaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViaAPI getAPI() {
|
public static ViaAPI getAPI() {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren