GreenAppleLogin/gal-velocity/src/main/java/net/limework/gal/ConfigLoader.java

35 lines
1.1 KiB
Java

package net.limework.gal;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.limework.gal.utils.config.AntiBot;
import net.limework.gal.utils.config.Configuration;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.concurrent.TimeUnit;
public class ConfigLoader implements Configuration {
private final String crackedChar;
private final AntiBot antiBot;
public ConfigLoader(File file) throws FileNotFoundException {
JsonObject jsonObject = JsonParser.parseReader(new FileReader(file)).getAsJsonObject();
this.crackedChar = jsonObject.get("default-cracked-char").getAsString();
JsonObject antiBotJson = jsonObject.getAsJsonObject("simple-anti-bot");
this.antiBot = new AntiBot(antiBotJson.get("max-connections").getAsInt(), antiBotJson.get("reset").getAsLong(), TimeUnit.MINUTES);
}
@Override
public String getCrackedChar() {
return this.crackedChar;
}
@Override
public AntiBot getAntiBot() {
return this.antiBot;
}
}