mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] FeaturesManager
This commit is contained in:
parent
4f5c3370ac
commit
cb5535b8ec
5 changed files with 87 additions and 0 deletions
|
@ -81,6 +81,7 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
|||
public final ReconfigurableManager reconfigurableManager;
|
||||
public final ConfigManager configManager;
|
||||
public final PingServerManager pingServerManager;
|
||||
public final FeaturesManager featuresManager;
|
||||
// HWID ban + anti-brutforce
|
||||
public final CertificateManager certificateManager;
|
||||
public final ProguardConf proguardConf;
|
||||
|
@ -147,6 +148,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
|||
authHookManager = new AuthHookManager();
|
||||
configManager = new ConfigManager();
|
||||
pingServerManager = new PingServerManager(this);
|
||||
featuresManager = new FeaturesManager(this);
|
||||
//Generate or set new Certificate API
|
||||
certificateManager.orgName = config.projectName;
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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()));
|
||||
}
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue