Skip to content

Commit

Permalink
[skip ci] the J
Browse files Browse the repository at this point in the history
  • Loading branch information
RacoonDog committed Aug 31, 2023
1 parent 715eda0 commit f91d656
Show file tree
Hide file tree
Showing 107 changed files with 13,674 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@ bin/
# fabric

run/

# ruh roh this is a teaser!!
src/main/java/org/
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import meteordevelopment.meteorclient.systems.Systems;
import meteordevelopment.meteorclient.systems.hud.Hud;
import meteordevelopment.meteorclient.systems.modules.Modules;
import net.fabricmc.loader.api.FabricLoader;

public final class TokyoSystems {
private static final Modules MODULES = Modules.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ private void onKeyPress(KeyPressEvent event) {

@EventHandler
private void onCharTyped(CharTypedEvent event) {
System.out.println("Inside event handler :O");
if (ClientSync.INSTANCE.syncInputs.get()) sendPacket(new InputSyncCharTypedC2CPacket(event.codePoint, event.modifiers));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void run() {
try {
DataInputStream in = new DataInputStream(socket.getInputStream());


while (!isInterrupted()) {
byte[] read = in.readAllBytes();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import io.github.racoondog.tokyo.Tokyo;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.tukaani.xz.LZMA2Options;
import org.tukaani.xz.XZInputStream;
import org.tukaani.xz.XZOutputStream;

import javax.crypto.Cipher;
import java.io.ByteArrayInputStream;
Expand All @@ -13,8 +16,6 @@
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Arrays;
import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -97,9 +98,7 @@ public static byte[] compress(byte[] bytes) {
if (bytes == null || bytes.length == 0) return bytes;

ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ConfigurableGZIPOutputStream gzip = new ConfigurableGZIPOutputStream(out)) {
//try (XZOutputStream gzip = new XZOutputStream(out, new LZMA2Options(9))) {
gzip.setLevel(Deflater.BEST_COMPRESSION);
try (XZOutputStream gzip = new XZOutputStream(out, new LZMA2Options(LZMA2Options.PRESET_MAX))) {
gzip.write(bytes);
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -112,7 +111,7 @@ public static byte[] uncompress(byte[] bytes) {

ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
try (GZIPInputStream ungzip = new GZIPInputStream(in)) {
try (XZInputStream ungzip = new XZInputStream(in)) {
byte[] buffer = new byte[256];
int n;
while ((n = ungzip.read(buffer)) >= 0) {
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/tukaani/xz/ARMOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* ARMOptions
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/

package org.tukaani.xz;

import java.io.InputStream;
import org.tukaani.xz.simple.ARM;

/**
* BCJ filter for little endian ARM instructions.
*/
public class ARMOptions extends BCJOptions {
private static final int ALIGNMENT = 4;

public ARMOptions() {
super(ALIGNMENT);
}

public FinishableOutputStream getOutputStream(FinishableOutputStream out,
ArrayCache arrayCache) {
return new SimpleOutputStream(out, new ARM(true, startOffset));
}

public InputStream getInputStream(InputStream in, ArrayCache arrayCache) {
return new SimpleInputStream(in, new ARM(false, startOffset));
}

FilterEncoder getFilterEncoder() {
return new BCJEncoder(this, BCJCoder.ARM_FILTER_ID);
}
}
37 changes: 37 additions & 0 deletions src/main/java/org/tukaani/xz/ARMThumbOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* ARMThumbOptions
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/

package org.tukaani.xz;

import java.io.InputStream;
import org.tukaani.xz.simple.ARMThumb;

/**
* BCJ filter for little endian ARM-Thumb instructions.
*/
public class ARMThumbOptions extends BCJOptions {
private static final int ALIGNMENT = 2;

public ARMThumbOptions() {
super(ALIGNMENT);
}

public FinishableOutputStream getOutputStream(FinishableOutputStream out,
ArrayCache arrayCache) {
return new SimpleOutputStream(out, new ARMThumb(true, startOffset));
}

public InputStream getInputStream(InputStream in, ArrayCache arrayCache) {
return new SimpleInputStream(in, new ARMThumb(false, startOffset));
}

FilterEncoder getFilterEncoder() {
return new BCJEncoder(this, BCJCoder.ARMTHUMB_FILTER_ID);
}
}
172 changes: 172 additions & 0 deletions src/main/java/org/tukaani/xz/ArrayCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/*
* ArrayCache
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/

package org.tukaani.xz;

/**
* Caches large arrays for reuse (base class and a dummy cache implementation).
* <p>
* When compressing or decompressing many (very) small files in a row, the
* time spent in construction of new compressor or decompressor objects
* can be longer than the time spent in actual compression or decompression.
* A large part of this initialization overhead comes from allocation and
* garbage collection of large arrays.
* <p>
* The {@code ArrayCache} API provides a way to cache large array allocations
* for reuse. It can give a major performance improvement when compressing or
* decompressing many tiny files. If you are only (de)compressing one or two
* files or the files a very big, array caching won't improve anything,
* although it won't make anything slower either.
* <p>
* <b>Important: The users of ArrayCache don't return the allocated arrays
* back to the cache in all situations.</b>
* This a reason why it's called a cache instead of a pool.
* If it is important to be able to return every array back to a cache,
* {@link ResettableArrayCache} can be useful.
* <p>
* In compressors (OutputStreams) the arrays are returned to the cache
* when a call to {@code finish()} or {@code close()} returns
* successfully (no exceptions are thrown).
* <p>
* In decompressors (InputStreams) the arrays are returned to the cache when
* the decompression is successfully finished ({@code read} returns {@code -1})
* or {@code close()} or {@code close(boolean)} is called. This is true even
* if closing throws an exception.
* <p>
* Raw decompressors don't support {@code close(boolean)}. With raw
* decompressors, if one wants to put the arrays back to the cache without
* closing the underlying {@code InputStream}, one can wrap the
* {@code InputStream} into {@link CloseIgnoringInputStream} when creating
* the decompressor instance. Then one can use {@code close()}.
* <p>
* Different cache implementations can be extended from this base class.
* All cache implementations must be thread safe.
* <p>
* This class also works as a dummy cache that simply calls {@code new}
* to allocate new arrays and doesn't try to cache anything. A statically
* allocated dummy cache is available via {@link #getDummyCache()}.
* <p>
* If no {@code ArrayCache} is specified when constructing a compressor or
* decompressor, the default {@code ArrayCache} implementation is used.
* See {@link #getDefaultCache()} and {@link #setDefaultCache(ArrayCache)}.
* <p>
* This is a class instead of an interface because it's possible that in the
* future we may want to cache other array types too. New methods can be
* added to this class without breaking existing cache implementations.
*
* @since 1.7
*
* @see BasicArrayCache
*/
public class ArrayCache {
/**
* Global dummy cache instance that is returned by {@code getDummyCache()}.
*/
private static final ArrayCache dummyCache = new ArrayCache();

/**
* Global default {@code ArrayCache} that is used when no other cache has
* been specified.
*/
private static volatile ArrayCache defaultCache = dummyCache;

/**
* Returns a statically-allocated {@code ArrayCache} instance.
* It can be shared by all code that needs a dummy cache.
*/
public static ArrayCache getDummyCache() {
return dummyCache;
}

/**
* Gets the default {@code ArrayCache} instance.
* This is a global cache that is used when the application
* specifies nothing else. The default is a dummy cache
* (see {@link #getDummyCache()}).
*/
public static ArrayCache getDefaultCache() {
// It's volatile so no need for synchronization.
return defaultCache;
}

/**
* Sets the default {@code ArrayCache} instance.
* Use with care. Other libraries using this package probably shouldn't
* call this function as libraries cannot know if there are other users
* of the xz package in the same application.
*/
public static void setDefaultCache(ArrayCache arrayCache) {
if (arrayCache == null)
throw new NullPointerException();

// It's volatile so no need for synchronization.
defaultCache = arrayCache;
}

/**
* Creates a new {@code ArrayCache} that does no caching
* (a dummy cache). If you need a dummy cache, you may want to call
* {@link #getDummyCache()} instead.
*/
public ArrayCache() {}

/**
* Allocates a new byte array.
* <p>
* This implementation simply returns {@code new byte[size]}.
*
* @param size the minimum size of the array to allocate;
* an implementation may return an array that
* is larger than the given {@code size}
*
* @param fillWithZeros if true, the caller expects that the first
* {@code size} elements in the array are zero;
* if false, the array contents can be anything,
* which speeds things up when reusing a cached
* array
*/
public byte[] getByteArray(int size, boolean fillWithZeros) {
return new byte[size];
}

/**
* Puts the given byte array to the cache. The caller must no longer
* use the array.
* <p>
* This implementation does nothing.
*/
public void putArray(byte[] array) {}

/**
* Allocates a new int array.
* <p>
* This implementation simply returns {@code new int[size]}.
*
* @param size the minimum size of the array to allocate;
* an implementation may return an array that
* is larger than the given {@code size}
*
* @param fillWithZeros if true, the caller expects that the first
* {@code size} elements in the array are zero;
* if false, the array contents can be anything,
* which speeds things up when reusing a cached
* array
*/
public int[] getIntArray(int size, boolean fillWithZeros) {
return new int[size];
}

/**
* Puts the given int array to the cache. The caller must no longer
* use the array.
* <p>
* This implementation does nothing.
*/
public void putArray(int[] array) {}
}
35 changes: 35 additions & 0 deletions src/main/java/org/tukaani/xz/BCJCoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* BCJCoder
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/

package org.tukaani.xz;

abstract class BCJCoder implements FilterCoder {
public static final long X86_FILTER_ID = 0x04;
public static final long POWERPC_FILTER_ID = 0x05;
public static final long IA64_FILTER_ID = 0x06;
public static final long ARM_FILTER_ID = 0x07;
public static final long ARMTHUMB_FILTER_ID = 0x08;
public static final long SPARC_FILTER_ID = 0x09;

public static boolean isBCJFilterID(long filterID) {
return filterID >= 0x04 && filterID <= 0x09;
}

public boolean changesSize() {
return false;
}

public boolean nonLastOK() {
return true;
}

public boolean lastOK() {
return false;
}
}
Loading

0 comments on commit f91d656

Please sign in to comment.