Skip to content

Instantly share code, notes, and snippets.

View zortax's full-sized avatar

Leonard Seibold zortax

View GitHub Profile
@zortax
zortax / Test.java
Last active January 28, 2021 03:30
inject Shadow instance
package de.zortax.flint.test;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import net.flintmc.framework.eventbus.event.subscribe.PostSubscribe;
import net.flintmc.framework.inject.primitive.InjectionHolder;
import net.flintmc.mcapi.chat.event.ChatSendEvent;
import net.flintmc.mcapi.player.ClientPlayer;
import net.flintmc.util.taskexecutor.TaskExecutor;

Keybase proof

I hereby claim:

  • I am zortax on github.
  • I am zortax (https://keybase.io/zortax) on keybase.
  • I have a public key ASAzpm1aRvFcjxo6SXv7h5g7kgzmzkyy-PBSCZ-1VNiVcQo

To claim this, I am signing this object:

@zortax
zortax / StringToPrimitive.java
Last active September 13, 2016 16:14
Simple Javamethod to convert a string to any primitive datatype (excluding char and String), may work with other datatypes if parse-method exists
public static <T> T stringToPrimitive(String str, Class<T> type) {
Method[] methods = type.getMethods();
for (Method m : methods) {
if (m.getName().startsWith("parse") && m.getParameters().length == 1 && m.getParameterTypes()[0].equals(String.class)) {
try {
return (T) m.invoke(null, str);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}