[FEATURE] FeaturesManager

This commit is contained in:
Gravita 2020-12-20 15:27:29 +07:00
parent 4f5c3370ac
commit cb5535b8ec
5 changed files with 87 additions and 0 deletions

View file

@ -81,6 +81,7 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
public final ReconfigurableManager reconfigurableManager; public final ReconfigurableManager reconfigurableManager;
public final ConfigManager configManager; public final ConfigManager configManager;
public final PingServerManager pingServerManager; public final PingServerManager pingServerManager;
public final FeaturesManager featuresManager;
// HWID ban + anti-brutforce // HWID ban + anti-brutforce
public final CertificateManager certificateManager; public final CertificateManager certificateManager;
public final ProguardConf proguardConf; public final ProguardConf proguardConf;
@ -147,6 +148,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
authHookManager = new AuthHookManager(); authHookManager = new AuthHookManager();
configManager = new ConfigManager(); configManager = new ConfigManager();
pingServerManager = new PingServerManager(this); pingServerManager = new PingServerManager(this);
featuresManager = new FeaturesManager(this);
//Generate or set new Certificate API //Generate or set new Certificate API
certificateManager.orgName = config.projectName; certificateManager.orgName = config.projectName;
/* /*

View file

@ -0,0 +1,35 @@
package pro.gravit.launchserver.manangers;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.Version;
import java.util.HashMap;
import java.util.Map;
public class FeaturesManager {
private transient LaunchServer server;
private Map<String, String> map;
public FeaturesManager(LaunchServer server) {
this.server = server;
map = new HashMap<>();
addFeatureInfo("version", Version.getVersion().getVersionString());
}
public Map<String, String> getMap() {
return map;
}
public String getFeatureInfo(String name) {
return map.get(name);
}
public String addFeatureInfo(String name, String featureInfo) {
return map.put(name, featureInfo);
}
public String removeFeatureInfo(String name) {
return map.remove(name);
}
}

View file

@ -0,0 +1,18 @@
package pro.gravit.launchserver.socket.response.management;
import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.FeaturesRequestEvent;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse;
public class FeaturesResponse extends SimpleResponse {
@Override
public String getType() {
return "features";
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
sendResult(new FeaturesRequestEvent(server.featuresManager.getMap()));
}
}

View file

@ -0,0 +1,21 @@
package pro.gravit.launcher.events.request;
import pro.gravit.launcher.events.RequestEvent;
import java.util.Map;
public class FeaturesRequestEvent extends RequestEvent {
public Map<String, String> features;
public FeaturesRequestEvent() {
}
public FeaturesRequestEvent(Map<String, String> features) {
this.features = features;
}
@Override
public String getType() {
return "features";
}
}

View file

@ -0,0 +1,11 @@
package pro.gravit.launcher.request.management;
import pro.gravit.launcher.events.request.FeaturesRequestEvent;
import pro.gravit.launcher.request.Request;
public class FeaturesRequest extends Request<FeaturesRequestEvent> {
@Override
public String getType() {
return "features";
}
}