com/hypixel/hytale/sneakythrow/SneakyThrow.java
package com.hypixel.hytale.sneakythrow;
import com.hypixel.hytale.function.consumer.TriConsumer;
import com.hypixel.hytale.sneakythrow.consumer.ThrowableBiConsumer;
import com.hypixel.hytale.sneakythrow.consumer.ThrowableConsumer;
import com.hypixel.hytale.sneakythrow.consumer.ThrowableIntConsumer;
import com.hypixel.hytale.sneakythrow.consumer.ThrowableTriConsumer;
import com.hypixel.hytale.sneakythrow.function.ThrowableBiFunction;
import com.hypixel.hytale.sneakythrow.function.ThrowableFunction;
import com.hypixel.hytale.sneakythrow.supplier.ThrowableIntSupplier;
import com.hypixel.hytale.sneakythrow.supplier.ThrowableSupplier;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public class SneakyThrow {
public SneakyThrow () {
}
@Nonnull
public static RuntimeException sneakyThrow (@Nonnull Throwable t) {
if (t == null ) {
throw new NullPointerException ("t" );
} else {
return (RuntimeException)sneakyThrow0(t);
}
}
private static <T extends Throwable > T sneakyThrow0 (Throwable t) throws T {
throw t;
}
public static <E extends Throwable > Runnable sneakyRunnable (ThrowableRunnable<E> runnable) {
return runnable;
}
public static <T, E extends Throwable > Supplier<T> sneakySupplier (ThrowableSupplier<T, E> supplier) {
return supplier;
}
public static <E extends Throwable > IntSupplier sneakySupplier (ThrowableIntSupplier<E> supplier) {
return supplier;
}
public static <T, E extends Throwable > Consumer<T> sneakyConsumer (ThrowableConsumer<T, E> consumer) {
return consumer;
}
public static <T, U, E extends Throwable > BiConsumer<T, U> sneakyConsumer (ThrowableBiConsumer<T, U, E> consumer) {
return consumer;
}
public static <T, U, V, E extends Throwable > TriConsumer<T, U, V> sneakyConsumer (ThrowableTriConsumer<T, U, V, E> consumer) {
return consumer;
}
public static <E extends Throwable > IntConsumer sneakyIntConsumer (ThrowableIntConsumer<E> consumer) {
return consumer;
}
public static <T, R, E extends Throwable > Function<T, R> sneakyFunction (ThrowableFunction<T, R, E> function) {
return function;
}
public static <T, U, R, E extends Throwable > BiFunction<T, U, R> sneakyFunction (ThrowableBiFunction<T, U, R, E> function) {
return function;
}
}
com/hypixel/hytale/sneakythrow/ThrowableRunnable.java
package com.hypixel.hytale.sneakythrow;
@FunctionalInterface
public interface ThrowableRunnable <E extends Throwable > extends Runnable {
default void run () {
try {
this .runNow();
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
void runNow () throws E;
}
com/hypixel/hytale/sneakythrow/consumer/ThrowableBiConsumer.java
package com.hypixel.hytale.sneakythrow.consumer;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.BiConsumer;
@FunctionalInterface
public interface ThrowableBiConsumer <T, U, E extends Throwable > extends BiConsumer <T, U> {
default void accept (T t, U u) {
try {
this .acceptNow(t, u);
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
void acceptNow (T var1, U var2) throws E;
}
com/hypixel/hytale/sneakythrow/consumer/ThrowableConsumer.java
package com.hypixel.hytale.sneakythrow.consumer;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.Consumer;
@FunctionalInterface
public interface ThrowableConsumer <T, E extends Throwable > extends Consumer <T> {
default void accept (T t) {
try {
this .acceptNow(t);
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
void acceptNow (T var1) throws E;
}
com/hypixel/hytale/sneakythrow/consumer/ThrowableIntConsumer.java
package com.hypixel.hytale.sneakythrow.consumer;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.IntConsumer;
@FunctionalInterface
public interface ThrowableIntConsumer <E extends Throwable > extends IntConsumer {
default void accept (int t) {
try {
this .acceptNow(t);
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
void acceptNow (int var1) throws E;
}
com/hypixel/hytale/sneakythrow/consumer/ThrowableTriConsumer.java
package com.hypixel.hytale.sneakythrow.consumer;
import com.hypixel.hytale.function.consumer.TriConsumer;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
@FunctionalInterface
public interface ThrowableTriConsumer <T, U, V, E extends Throwable > extends TriConsumer <T, U, V> {
default void accept (T t, U u, V v) {
try {
this .acceptNow(t, u, v);
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
void acceptNow (T var1, U var2, V var3) throws E;
}
com/hypixel/hytale/sneakythrow/function/ThrowableBiFunction.java
package com.hypixel.hytale.sneakythrow.function;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.BiFunction;
@FunctionalInterface
public interface ThrowableBiFunction <T, U, R, E extends Throwable > extends BiFunction <T, U, R> {
default R apply (T t, U u) {
try {
return (R)this .applyNow(t, u);
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
R applyNow (T var1, U var2) throws E;
}
com/hypixel/hytale/sneakythrow/function/ThrowableFunction.java
package com.hypixel.hytale.sneakythrow.function;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.Function;
@FunctionalInterface
public interface ThrowableFunction <T, R, E extends Throwable > extends Function <T, R> {
default R apply (T t) {
try {
return (R)this .applyNow(t);
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
R applyNow (T var1) throws E;
}
com/hypixel/hytale/sneakythrow/supplier/ThrowableIntSupplier.java
package com.hypixel.hytale.sneakythrow.supplier;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.IntSupplier;
@FunctionalInterface
public interface ThrowableIntSupplier <E extends Throwable > extends IntSupplier {
default int getAsInt () {
try {
return this .getAsIntNow();
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
int getAsIntNow () throws E;
}
com/hypixel/hytale/sneakythrow/supplier/ThrowableSupplier.java
package com.hypixel.hytale.sneakythrow.supplier;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.util.function.Supplier;
@FunctionalInterface
public interface ThrowableSupplier <T, E extends Throwable > extends Supplier <T> {
default T get () {
try {
return (T)this .getNow();
} catch (Throwable e) {
throw SneakyThrow.sneakyThrow(e);
}
}
T getNow () throws E;
}