3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Create builder for ViaManager

Dieser Commit ist enthalten in:
Matsv 2016-09-25 21:33:47 +02:00
Ursprung 573374866b
Commit e56bce2f31
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
4 geänderte Dateien mit 16 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -1,3 +1 @@
Handle injector errors
Important: Create builder for ViaManager which allows supplying on the command exectutor, injector, platform :D

Datei anzeigen

@ -45,8 +45,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
public ViaVersionPlugin() {
// Config magic
conf = new ViaConfig(this);
// Command handler
commandHandler = new BukkitCommandHandler();
// Init platform
Via.init(this);
Via.init(ViaManager.builder()
.platform(this)
.commandHandler(commandHandler)
.injector(new BukkitViaInjector())
.build());
// For compatibility
ViaVersion.setInstance(this);
@ -95,7 +101,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
Via.getManager().init();
}
getCommand("viaversion").setExecutor(commandHandler = new BukkitCommandHandler());
getCommand("viaversion").setExecutor(commandHandler);
getCommand("viaversion").setTabCompleter(commandHandler);
// Warn them if they have anti-xray on and they aren't using spigot

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import us.myles.ViaVersion.api.data.UserConnection;
@ -18,9 +19,10 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@Getter
@Builder
public class ViaManager {
private ViaPlatform platform;
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
private ViaPlatform platform;
private ViaProviders providers = new ViaProviders();
@Setter
private boolean debug = false;
@ -29,10 +31,6 @@ public class ViaManager {
private ViaCommandHandler commandHandler;
private ViaPlatformLoader loader;
public ViaManager(ViaPlatform platform) {
this.platform = platform;
}
public void init() {
if (System.getProperty("ViaVersion") != null) {
// Reload?

Datei anzeigen

@ -11,10 +11,11 @@ public class Via {
@Getter
private static ViaManager manager;
public static void init(ViaPlatform platform) {
Validate.isTrue(platform == null, "Platform is already set");
Via.platform = platform;
Via.manager = new ViaManager(platform);
public static void init(ViaManager viaManager) {
Validate.isTrue(manager == null, "ViaManager is already set");
Via.platform = viaManager.getPlatform();
Via.manager = viaManager;
}
public static ViaAPI getAPI() {