forked from SteamWar/SteamWar
Update TechHiderWrapper and add orientation pattern
This commit is contained in:
+31
-1
@@ -48,6 +48,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.BitSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TechHiderWrapper extends StateDependent implements TechHider.LocationEvaluator, Listener {
|
||||
@@ -145,7 +146,36 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
||||
|
||||
public long getPattern(Player player) {
|
||||
try {
|
||||
return ByteBuffer.wrap(cipher.doFinal(ByteBuffer.wrap(new byte[8]).putLong(SteamwarUser.get(player.getUniqueId()).getId()).array())).getLong();
|
||||
byte[] bytes = new byte[6];
|
||||
long id = SteamwarUser.get(player.getUniqueId()).getId();
|
||||
|
||||
bytes[0] = (byte) (id & 0xFF);
|
||||
bytes[1] = (byte) ((id >>> 8) & 0xFF);
|
||||
bytes[2] = (byte) ((id >>> 16) & 0xFF);
|
||||
bytes[3] = (byte) ((id >>> 24) & 0xFF);
|
||||
bytes[4] = (byte) ((id >>> 32) & 0xFF);
|
||||
bytes[5] = (byte) ((id >>> 40) & 0xFF);
|
||||
|
||||
bytes = cipher.doFinal(bytes);
|
||||
|
||||
id = bytes[0] & 0xFFL |
|
||||
((bytes[1] & 0xFFL) << 8) |
|
||||
((bytes[2] & 0xFFL) << 16) |
|
||||
((bytes[3] & 0xFFL) << 24) |
|
||||
((bytes[4] & 0xFFL) << 32) |
|
||||
((bytes[5] & 0xFFL) << 40);
|
||||
|
||||
long result = 0b0000000000000000000000000001001100000001000101110000001101110111L;
|
||||
for (int i = 0; i < 64; i++) {
|
||||
int mask = 1 << i;
|
||||
if ((result & mask) != 0) continue;
|
||||
if ((id & 1) == 1) {
|
||||
result |= mask;
|
||||
}
|
||||
id = id >>> 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (IllegalBlockSizeException | BadPaddingException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user