Make API class a singleton

This commit is contained in:
Eric 2018-08-02 16:12:34 +02:00
parent 8da3ac3b92
commit 2fca599c04

View File

@ -1,20 +1,26 @@
package org.codemc.worldguardwrapper; package org.codemc.worldguardwrapper;
import lombok.experimental.Delegate;
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation; import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
import lombok.experimental.Delegate;
public class WorldGuardWrapper implements IWorldGuardImplementation { public class WorldGuardWrapper implements IWorldGuardImplementation {
@Delegate @Delegate
private IWorldGuardImplementation implementation; private IWorldGuardImplementation delegate;
public WorldGuardWrapper() { private WorldGuardWrapper() {
// TODO: better way to detect version // TODO: better way to detect version
try { try {
Class.forName("com.sk89q.worldguard.WorldGuard"); Class.forName("com.sk89q.worldguard.WorldGuard");
implementation = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation(); delegate = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
implementation = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation(); delegate = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation();
} }
} }
public WorldGuardWrapper getInstance() {
return this;
}
} }