aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorhackthetime <l4bg0jb7@duck.com>2023-10-16 21:03:20 +0200
committerhackthetime <l4bg0jb7@duck.com>2023-10-16 21:03:20 +0200
commit70dbcacd50bbde0829958599ac0454610a874214 (patch)
tree2ec8c427449fa84df38aba9f55000b24ea768211 /common
parente9d6a8aa983ac8e3eca7984a774af592b59cc33d (diff)
downloadBBsentials-70dbcacd50bbde0829958599ac0454610a874214.tar.gz
BBsentials-70dbcacd50bbde0829958599ac0454610a874214.tar.bz2
BBsentials-70dbcacd50bbde0829958599ac0454610a874214.zip
things related mojang auth. seems to be broken?
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/client/Config.java1
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java6
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java65
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java1
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java5
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java2
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java1
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java15
8 files changed, 71 insertions, 25 deletions
diff --git a/common/src/main/java/de/hype/bbsentials/common/client/Config.java b/common/src/main/java/de/hype/bbsentials/common/client/Config.java
index 50f898d..91b4418 100644
--- a/common/src/main/java/de/hype/bbsentials/common/client/Config.java
+++ b/common/src/main/java/de/hype/bbsentials/common/client/Config.java
@@ -32,6 +32,7 @@ public class Config implements Serializable {
// Set via load / default you may change these
public boolean overrideBingoTime = false;
public boolean connectToBeta = false;
+ public boolean useMojangAuth = false;
public String bbServerURL = "localhost";
public String apiKey = "";
diff --git a/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java b/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java
index eaf3ee1..74a7757 100644
--- a/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java
+++ b/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java
@@ -7,15 +7,15 @@ import java.util.List;
public interface DebugThread extends Runnable {
@Override
- public default void run() {
+ default void run() {
loop();
//place a breakpoint for only this thread here.
}
- public default void loop() {
+ default void loop() {
}
- public default List<String> test() {
+ default List<String> test() {
return Collections.singletonList("");
}
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
index 6dd9edb..69be09b 100644
--- a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
+++ b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
@@ -17,6 +17,7 @@ import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.*;
+import java.math.BigInteger;
import java.net.Socket;
import java.net.SocketException;
import java.security.KeyManagementException;
@@ -27,6 +28,7 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;
+import java.util.Random;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -45,7 +47,6 @@ public class BBsentialConnection {
}
-
public static boolean isCommandSafe(String command) {
if (command.startsWith("/p ") || command.startsWith("/party ") || command.startsWith("/boop ") || command.startsWith("/msg ") || command.startsWith("/hub ")) {
return true;
@@ -66,7 +67,6 @@ public class BBsentialConnection {
}
-
public void connect(String serverIP, int serverPort) {
// Enable SSL handshake debugging
System.setProperty("javax.net.debug", "ssl,handshake");
@@ -234,15 +234,6 @@ public class BBsentialConnection {
public void onMessageReceived(String message) {
if (!PacketUtils.handleIfPacket(this, message)) {
if (message.startsWith("H-")) {
- if (message.equals("H-BB-Login: ")) {
- Chat.sendPrivateMessageToSelfSuccess("Logging into BBsentials-online");
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- sendPacket(new RequestConnectPacket(BBsentials.config.getMCUUID(), BBsentials.getConfig().getApiKey(), BBsentials.getConfig().getApiVersion(), AuthenticationConstants.DATABASE));
- }
}
else {
Chat.sendPrivateMessageToSelfSuccess("BB: " + message);
@@ -295,8 +286,9 @@ public class BBsentialConnection {
}
public void onSplashNotifyPacket(SplashNotifyPacket packet) {
+ //influencing the delay in any way is disallowed!
int waitTime;
- if (packet.splasherUsername.equals(BBsentials.config.getUsername())&& BBsentials.config.autoSplashStatusUpdates) {
+ if (packet.splasherUsername.equals(BBsentials.config.getUsername()) && BBsentials.config.autoSplashStatusUpdates) {
Chat.sendPrivateMessageToSelfInfo("The Splash Update Statuses will be updatet automatically for you. If you need to do something manually go into Discord Splash Dashboard");
SplashStatusUpdateListener splashStatusUpdateListener = new SplashStatusUpdateListener(this, packet);
BBsentials.splashStatusUpdateListener = splashStatusUpdateListener;
@@ -336,7 +328,7 @@ public class BBsentialConnection {
if (!(packet.extraMessage == null || packet.extraMessage.isEmpty())) {
tellrawText = tellrawText.replace("@extramessage", " : " + packet.extraMessage);
}
- Chat.sendPrivateMessageToSelfText(new Message(tellrawText,""));
+ Chat.sendPrivateMessageToSelfText(new Message(tellrawText, ""));
}
}
else {
@@ -348,7 +340,8 @@ public class BBsentialConnection {
public void onMiningEventPacket(MiningEventPacket packet) {
if (!BBsentials.config.toDisplayConfig.getValue("disableAll")) {
//its will returns false cause disabled is checked already before.
- if (BBsentials.config.toDisplayConfig.blockChEvents && packet.island.equals(Islands.CRYSTAL_HOLLOWS)) return;
+ if (BBsentials.config.toDisplayConfig.blockChEvents && packet.island.equals(Islands.CRYSTAL_HOLLOWS))
+ return;
if (!(BBsentials.config.toDisplayConfig.allEvents)) {
if (packet.event.equals(MiningEvents.RAFFLE)) {
if (!BBsentials.config.toDisplayConfig.raffle) return;
@@ -483,7 +476,7 @@ public class BBsentialConnection {
Chat.sendCommand("/p " + packet.type + String.join(" ", packet.users));
}
else {
- Chat.sendPrivateMessageToSelfImportantInfo("Blocked a Party Command from the Server: "+packet.type+" : "+String.join(" ", packet.users));
+ Chat.sendPrivateMessageToSelfImportantInfo("Blocked a Party Command from the Server: " + packet.type + " : " + String.join(" ", packet.users));
}
}
@@ -499,20 +492,50 @@ public class BBsentialConnection {
}
}
+ public void onRequestAuthentication(RequestAuthentication packet) {
+ Chat.sendPrivateMessageToSelfSuccess("Logging into BBsentials-online");
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ Random r1 = new Random();
+ Random r2 = new Random(System.identityHashCode(new Object()));
+ BigInteger random1Bi = new BigInteger(128, r1);
+ BigInteger random2Bi = new BigInteger(128, r2);
+ BigInteger serverBi = random1Bi.xor(random2Bi);
+ String clientRandom = serverBi.toString(16);
+
+ String serverId = clientRandom + packet.serverIdSuffix;
+ if (BBsentials.config.useMojangAuth) {
+ String serverID = EnvironmentCore.mcUtils.mojangAuth(serverId);
+ sendPacket(new RequestConnectPacket(BBsentials.config.getMCUUID(), serverID, BBsentials.getConfig().getApiVersion(), AuthenticationConstants.MOJANG));
+ }
+ else {
+ sendPacket(new RequestConnectPacket(BBsentials.config.getMCUUID(), BBsentials.getConfig().getApiKey(), BBsentials.getConfig().getApiVersion(), AuthenticationConstants.DATABASE));
+ }
+ }
+
public boolean showChChest(ChChestItem[] items) {
if (BBsentials.config.toDisplayConfig.allChChestItem) return true;
for (ChChestItem item : items) {
if (BBsentials.config.toDisplayConfig.customChChestItem && item.isCustom()) return true;
if (BBsentials.config.toDisplayConfig.allRoboPart && item.isRoboPart()) return true;
- if (BBsentials.config.toDisplayConfig.prehistoricEgg && item.equals(ChChestItems.PrehistoricEgg)) return true;
- if (BBsentials.config.toDisplayConfig.pickonimbus2000 && item.equals(ChChestItems.Pickonimbus2000)) return true;
+ if (BBsentials.config.toDisplayConfig.prehistoricEgg && item.equals(ChChestItems.PrehistoricEgg))
+ return true;
+ if (BBsentials.config.toDisplayConfig.pickonimbus2000 && item.equals(ChChestItems.Pickonimbus2000))
+ return true;
if (BBsentials.config.toDisplayConfig.controlSwitch && item.equals(ChChestItems.ControlSwitch)) return true;
if (BBsentials.config.toDisplayConfig.electronTransmitter && item.equals(ChChestItems.ElectronTransmitter))
return true;
- if (BBsentials.config.toDisplayConfig.robotronReflector && item.equals(ChChestItems.RobotronReflector)) return true;
- if (BBsentials.config.toDisplayConfig.superliteMotor && item.equals(ChChestItems.SuperliteMotor)) return true;
- if (BBsentials.config.toDisplayConfig.syntheticHeart && item.equals(ChChestItems.SyntheticHeart)) return true;
- if (BBsentials.config.toDisplayConfig.flawlessGemstone && item.equals(ChChestItems.FlawlessGemstone)) return true;
+ if (BBsentials.config.toDisplayConfig.robotronReflector && item.equals(ChChestItems.RobotronReflector))
+ return true;
+ if (BBsentials.config.toDisplayConfig.superliteMotor && item.equals(ChChestItems.SuperliteMotor))
+ return true;
+ if (BBsentials.config.toDisplayConfig.syntheticHeart && item.equals(ChChestItems.SyntheticHeart))
+ return true;
+ if (BBsentials.config.toDisplayConfig.flawlessGemstone && item.equals(ChChestItems.FlawlessGemstone))
+ return true;
if (BBsentials.config.toDisplayConfig.jungleHeart && item.equals(ChChestItems.JungleHeart)) return true;
}
return false;
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java
index 52f1ea1..ebc844c 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java
@@ -4,4 +4,5 @@ public class AuthenticationConstants {
//Authentication Types
public static final String MOJANG = "MOJANG";
public static final String DATABASE = "DATABASE";
+ public static final String REGISTER = "REGISTER";
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java
index 43835c6..9b9a976 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java
@@ -10,5 +10,8 @@ public enum InternalReasonConstants {
INVALID_LOGIN,
KICKED,
ANOTHER_LOGIN,
- SERVER_RESTART
+ SERVER_RESTART,
+ NOT_REGISTERED,
+ ON_COOLDOWN,
+ OTHER
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java
index 493785a..c007d31 100644
--- a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java
+++ b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java
@@ -13,4 +13,6 @@ public interface MCUtils {
void playsound(String eventName);
int getPotTime();
+
+ String mojangAuth(String serverId);
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java b/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java
index 23368d8..8d8eaec 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java
@@ -36,6 +36,7 @@ public class PacketManager {
packets.add(new Packet<>(SplashNotifyPacket.class, connection::onSplashNotifyPacket));
packets.add(new Packet<>(SystemMessagePacket.class, connection::onSystemMessagePacket));
packets.add(new Packet<>(WelcomeClientPacket.class, connection::onWelcomePacket));
+ packets.add(new Packet<>(RequestAuthentication.class, connection::onRequestAuthentication));
}
// Method to handle a received packet
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java
new file mode 100644
index 0000000..81ea9fe
--- /dev/null
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java
@@ -0,0 +1,15 @@
+package de.hype.bbsentials.common.packets.packets;
+
+import de.hype.bbsentials.common.packets.AbstractPacket;
+
+public class RequestAuthentication extends AbstractPacket {
+
+ public final String serverIdSuffix;
+ public final int serverVersion;
+
+ public RequestAuthentication(String serverIdSuffix, int serverVersion) {
+ super(1, 1); //Min and Max supported Version
+ this.serverIdSuffix = serverIdSuffix;
+ this.serverVersion = serverVersion;
+ }
+}