66 lines
1.9 KiB
Java
66 lines
1.9 KiB
Java
package net.limework.gal;
|
|
|
|
import com.google.inject.Inject;
|
|
import com.velocitypowered.api.plugin.Plugin;
|
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
|
import com.velocitypowered.api.proxy.ProxyServer;
|
|
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.Objects;
|
|
import java.util.logging.Logger;
|
|
|
|
@Plugin(name = "GreenAppleLogin", id = "greenapplelogin", version = "1.0.0", description = "Plugin that handle cracked + premium")
|
|
public class VelocityGalPlugin {
|
|
|
|
private final ProxyServer proxyServer;
|
|
private final Logger logger;
|
|
private final File dataFolder;
|
|
private final ConfigLoader config;
|
|
|
|
@Inject
|
|
public VelocityGalPlugin(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataDirectory) {
|
|
this.proxyServer = proxyServer;
|
|
this.logger = logger;
|
|
this.dataFolder = dataDirectory.toFile();
|
|
|
|
if (this.dataFolder.mkdir()) {
|
|
getLogger().info("Created Plugin data folder.");
|
|
}
|
|
File file = new File(getDataFolder(), "config.json");
|
|
if (!file.exists()) {
|
|
try (InputStream in = getClass().getClassLoader().getResourceAsStream("config.json")) {
|
|
Files.copy(Objects.requireNonNull(in), file.toPath());
|
|
} catch (NullPointerException | IOException e) {
|
|
throw new RuntimeException("unable to load config file", e);
|
|
}
|
|
}
|
|
try {
|
|
this.config = new ConfigLoader(file);
|
|
} catch (FileNotFoundException e) {
|
|
throw new RuntimeException("unable to load config file", e);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ProxyServer getProxyServer() {
|
|
return proxyServer;
|
|
}
|
|
|
|
public Logger getLogger() {
|
|
return logger;
|
|
}
|
|
|
|
public File getDataFolder() {
|
|
return dataFolder;
|
|
}
|
|
}
|