Bungeecord support added x2
This commit is contained in:
parent
f5569b2346
commit
df01b38949
@ -1,20 +1,28 @@
|
|||||||
package com.alterdekim.xcraft.auth.bungee;
|
package com.alterdekim.xcraft.auth.bungee;
|
||||||
|
|
||||||
import com.alterdekim.xcraft.auth.SaltNic;
|
import com.alterdekim.xcraft.auth.SaltNic;
|
||||||
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
|
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||||
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import sun.misc.Unsafe;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.alterdekim.xcraft.auth.lib.Patcher.patchAuthLib;
|
import static com.alterdekim.xcraft.auth.lib.Patcher.patchAuthLib;
|
||||||
|
|
||||||
public class XCraft extends Plugin {
|
public class XCraft extends Plugin implements Listener {
|
||||||
|
|
||||||
private static SaltNic server = null;
|
private static SaltNic server = null;
|
||||||
|
|
||||||
@ -25,6 +33,7 @@ public class XCraft extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
getProxy().getPluginManager().registerListener(this, this);
|
||||||
try {
|
try {
|
||||||
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
|
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
|
||||||
SERVER_PORT = config.getInt("public_port");
|
SERVER_PORT = config.getInt("public_port");
|
||||||
@ -43,19 +52,25 @@ public class XCraft extends Plugin {
|
|||||||
getLogger().severe("Failed to start SaltNic server: " + e.getMessage());
|
getLogger().severe("Failed to start SaltNic server: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getLogger().info("Patching AuthLib URLs...");
|
}
|
||||||
while(true) {
|
|
||||||
try {
|
@EventHandler
|
||||||
patchAuthLib(getLogger(), INTERNAL_PORT);
|
public void onLogin(LoginEvent event) {
|
||||||
getLogger().info("AuthLib URLs patched successfully!");
|
try {
|
||||||
return;
|
if( server.getSessionValue(event.getConnection().getUniqueId().toString()) ) {
|
||||||
} catch (Exception e) {
|
server.deleteSessionRequest(event.getConnection().getUniqueId().toString());
|
||||||
e.printStackTrace();
|
UUID customUUID = UUID.nameUUIDFromBytes(("xcraft-" + event.getConnection().getName()).getBytes());
|
||||||
getLogger().severe("Failed to patch AuthLib: " + e.getMessage());
|
event.setCancelled(false);
|
||||||
|
event.getConnection().setUniqueId(customUUID);
|
||||||
|
getLogger().info("Player " + event.getConnection().getName() + " is now using UUID: " + customUUID);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
|
@ -172,6 +172,17 @@ public class SaltNic extends NanoHTTPD {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSessionValue(String uuid) {
|
||||||
|
if( this.sessions.containsKey(uuid) ) {
|
||||||
|
return this.sessions.get(uuid);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSessionRequest(String uuid) {
|
||||||
|
this.sessions.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
private Response handleSetModel(IHTTPSession session) {
|
private Response handleSetModel(IHTTPSession session) {
|
||||||
try {
|
try {
|
||||||
String playerUUID = session.getParameters().get("uuid").get(0);
|
String playerUUID = session.getParameters().get("uuid").get(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user