mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-27 23:46:00 +00:00
Added passphrase Auth to the handshake
This commit is contained in:
1 parent
3cd002769f
commit
559211c64f
4 files changed
+48
-3
No files matched your search
@@ -38,6 +38,7 @@ import mcp.mobius.opis.data.holders.newtypes.DataTileEntity;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataTileEntityRender;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataTiming;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataTimingMillisecond;
|
||||
import mcp.mobius.opis.data.holders.newtypes.NexusAuth;
|
||||
import mcp.mobius.opis.data.holders.newtypes.NexusData;
|
||||
import mcp.mobius.opis.data.holders.stats.StatAbstract;
|
||||
import mcp.mobius.opis.data.holders.stats.StatsChunk;
|
||||
@@ -82,8 +83,9 @@ public enum DataType {
|
||||
DATATIMINGMILLISECOND (DataTimingMillisecond.class),
|
||||
STATABSTRACT (StatAbstract.class),
|
||||
STATSCHUNK (StatsChunk.class),
|
||||
NEXUSDATA (NexusData.class);
|
||||
|
||||
NEXUSDATA (NexusData.class),
|
||||
NEXUSAUTH (NexusAuth.class);
|
||||
|
||||
private Class clazz;
|
||||
private static HashBiMap<DataType, Class> bimap = HashBiMap.create(50);
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package mcp.mobius.opis.data.holders.newtypes;
|
||||
|
||||
import mcp.mobius.opis.data.holders.ISerializable;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialInt;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialLong;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialString;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
|
||||
public class NexusAuth implements ISerializable {
|
||||
|
||||
SerialString uuid;
|
||||
SerialString passphrase;
|
||||
|
||||
public NexusAuth(String uuid, String passphrase){
|
||||
this.uuid = new SerialString(uuid);
|
||||
this.passphrase = new SerialString(passphrase);
|
||||
}
|
||||
|
||||
public NexusAuth(SerialString uuid, SerialString passphrase){
|
||||
this.uuid = uuid;
|
||||
this.passphrase = passphrase;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteArrayDataOutput stream){
|
||||
this.uuid.writeToStream(stream);
|
||||
this.passphrase.writeToStream(stream);
|
||||
}
|
||||
|
||||
public static NexusAuth readFromStream(ByteArrayDataInput stream){
|
||||
return new NexusAuth(
|
||||
SerialString.readFromStream(stream),
|
||||
SerialString.readFromStream(stream)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,7 @@ public class NexusClient implements Runnable {
|
||||
|
||||
String host = "localhost";
|
||||
String uuid = "";
|
||||
String pass = "";
|
||||
Integer port = 8013;
|
||||
Boolean active = false;
|
||||
|
||||
@@ -138,6 +139,7 @@ public class NexusClient implements Runnable {
|
||||
this.port = Integer.valueOf(prop.getProperty("port"));
|
||||
this.active = Boolean.valueOf(prop.getProperty("active"));
|
||||
this.uuid = prop.getProperty("uuid");
|
||||
this.pass = prop.getProperty("passphrase");
|
||||
}
|
||||
|
||||
private void writeConfig(String filename){
|
||||
@@ -151,6 +153,7 @@ public class NexusClient implements Runnable {
|
||||
prop.setProperty("port", this.port.toString());
|
||||
prop.setProperty("active", this.active.toString());
|
||||
prop.setProperty("uuid", this.uuid);
|
||||
prop.setProperty("passphrase", this.pass);
|
||||
prop.store(output, null);
|
||||
|
||||
output.close();
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import mcp.mobius.opis.modOpis;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialLong;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialString;
|
||||
import mcp.mobius.opis.data.holders.newtypes.NexusAuth;
|
||||
import mcp.mobius.opis.data.managers.StringCache;
|
||||
import mcp.mobius.opis.events.PlayerTracker;
|
||||
import mcp.mobius.opis.network.PacketBase;
|
||||
@@ -38,7 +39,7 @@ public class NexusInboundHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
//PlayerTracker.INSTANCE.playersSwing.add(fakePlayer);
|
||||
//PlayerTracker.INSTANCE.playerTab.put(fakePlayer, SelectedTab.SUMMARY);
|
||||
RConHandler.sendToPlayerNexus(new NetDataValue(Message.NEXUS_UUID, new SerialString(NexusClient.instance.uuid)), fakePlayer);
|
||||
RConHandler.sendToPlayerNexus(new NetDataValue(Message.NEXUS_UUID, new NexusAuth(NexusClient.instance.uuid, NexusClient.instance.pass)), fakePlayer);
|
||||
RConHandler.sendToPlayerNexus(new NetDataValue(Message.STATUS_CURRENT_TIME, new SerialLong(System.currentTimeMillis())), fakePlayer);
|
||||
StringCache.INSTANCE.syncCache(fakePlayer);
|
||||
|
||||
|
||||
Reference in new issue
Block a user