From a6a263cae1451eeaad9bbe4edc678a583232b272 Mon Sep 17 00:00:00 2001 From: Manevolent Date: Fri, 10 Aug 2018 22:42:44 -0400 Subject: [PATCH] get rid of JavaFX --- .../client/LocalClientHandlerConnecting.java | 2 +- .../InitPacketTransformation.java | 2 +- .../transformation/PacketTransformation.java | 2 +- .../client/AbstractTeamspeakClientSocket.java | 2 +- .../client/LocalTeamspeakClientSocket.java | 2 +- .../com/github/manevolent/ts3j/util/Pair.java | 100 ++++++++++++++++++ .../github/manevolent/ts3j/util/Ts3Crypt.java | 2 +- 7 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/github/manevolent/ts3j/util/Pair.java diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerConnecting.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerConnecting.java index b99d34f..af5c2ca 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerConnecting.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerConnecting.java @@ -10,7 +10,7 @@ import com.github.manevolent.ts3j.protocol.packet.PacketBody8Init1; import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket; import com.github.manevolent.ts3j.util.Ts3Crypt; import com.github.manevolent.ts3j.util.Ts3Debugging; -import javafx.util.Pair; +import com.github.manevolent.ts3j.util.Pair; import org.bouncycastle.math.ec.ECPoint; import java.io.IOException; diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/InitPacketTransformation.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/InitPacketTransformation.java index b245fcb..9d54fb6 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/InitPacketTransformation.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/InitPacketTransformation.java @@ -2,7 +2,7 @@ package com.github.manevolent.ts3j.protocol.packet.transformation; import com.github.manevolent.ts3j.protocol.header.PacketHeader; -import javafx.util.Pair; +import com.github.manevolent.ts3j.util.Pair; public class InitPacketTransformation extends PacketTransformation { private static final byte[] key = diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/PacketTransformation.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/PacketTransformation.java index a1f7da2..b9cead1 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/PacketTransformation.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/transformation/PacketTransformation.java @@ -4,7 +4,7 @@ import com.github.manevolent.ts3j.protocol.Packet; import com.github.manevolent.ts3j.protocol.ProtocolRole; import com.github.manevolent.ts3j.protocol.header.PacketHeader; import com.github.manevolent.ts3j.util.Ts3Crypt; -import javafx.util.Pair; +import com.github.manevolent.ts3j.util.Pair; import org.bouncycastle.crypto.CipherParameters; import org.bouncycastle.crypto.InvalidCipherTextException; import org.bouncycastle.crypto.engines.AESEngine; diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java index 665b8bf..196f544 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java @@ -20,7 +20,7 @@ import com.github.manevolent.ts3j.protocol.socket.AbstractTeamspeakSocket; import com.github.manevolent.ts3j.util.QuickLZ; import com.github.manevolent.ts3j.util.Ts3Crypt; import com.github.manevolent.ts3j.util.Ts3Debugging; -import javafx.util.Pair; +import com.github.manevolent.ts3j.util.Pair; import org.bouncycastle.crypto.InvalidCipherTextException; import java.io.IOException; diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index 52040bf..d79860c 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -22,7 +22,7 @@ import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command; import com.github.manevolent.ts3j.protocol.packet.statistics.PacketStatistics; import com.github.manevolent.ts3j.util.HighPrecisionRecurrentTask; import com.github.manevolent.ts3j.util.Ts3Debugging; -import javafx.util.Pair; +import com.github.manevolent.ts3j.util.Pair; import java.io.IOException; import java.net.*; diff --git a/src/main/java/com/github/manevolent/ts3j/util/Pair.java b/src/main/java/com/github/manevolent/ts3j/util/Pair.java new file mode 100644 index 0000000..5cc3c1a --- /dev/null +++ b/src/main/java/com/github/manevolent/ts3j/util/Pair.java @@ -0,0 +1,100 @@ +package com.github.manevolent.ts3j.util; + +import java.io.Serializable; + +/** + *

A convenience class to represent name-value pairs.

+ */ +public class Pair implements Serializable { + + /** + * Key of this Pair. + */ + private K key; + + /** + * Gets the key for this pair. + * @return key for this pair + */ + public K getKey() { return key; } + + /** + * Value of this this Pair. + */ + private V value; + + /** + * Gets the value for this pair. + * @return value for this pair + */ + public V getValue() { return value; } + + /** + * Creates a new pair + * @param key The key for this pair + * @param value The value to use for this pair + */ + public Pair(K key, V value) { + this.key = key; + this.value = value; + } + + /** + *

String representation of this + * Pair.

+ * + *

The default name/value delimiter '=' is always used.

+ * + * @return String representation of this Pair + */ + @Override + public String toString() { + return key + "=" + value; + } + + /** + *

Generate a hash code for this Pair.

+ * + *

The hash code is calculated using both the name and + * the value of the Pair.

+ * + * @return hash code for this Pair + */ + @Override + public int hashCode() { + // name's hashCode is multiplied by an arbitrary prime number (13) + // in order to make sure there is a difference in the hashCode between + // these two parameters: + // name: a value: aa + // name: aa value: a + return key.hashCode() * 13 + (value == null ? 0 : value.hashCode()); + } + + /** + *

Test this Pair for equality with another + * Object.

+ * + *

If the Object to be tested is not a + * Pair or is null, then this method + * returns false.

+ * + *

Two Pairs are considered equal if and only if + * both the names and values are equal.

+ * + * @param o the Object to test for + * equality with this Pair + * @return true if the given Object is + * equal to this Pair else false + */ + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof Pair) { + Pair pair = (Pair) o; + if (key != null ? !key.equals(pair.key) : pair.key != null) return false; + if (value != null ? !value.equals(pair.value) : pair.value != null) return false; + return true; + } + return false; + } + } \ No newline at end of file diff --git a/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java b/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java index a1cea6c..635ef39 100644 --- a/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java +++ b/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java @@ -7,7 +7,7 @@ import Punisher.NaCl.Internal.Ed25519Ref10.ScalarOperations; import Punisher.NaCl.Internal.Sha512; import com.github.manevolent.ts3j.identity.*; import com.github.manevolent.ts3j.license.License; -import javafx.util.Pair; +import com.github.manevolent.ts3j.util.Pair; import org.bouncycastle.asn1.*; import org.bouncycastle.crypto.digests.SHA256Digest; import org.bouncycastle.crypto.params.ECDomainParameters;