Skip to content

Instantly share code, notes, and snippets.

View Geolykt's full-sized avatar
🍴
Fork, fork

Geolykt

🍴
Fork, fork
View GitHub Profile
public class DIJavaPlugin extends JavaPlugin {
public void onEnable() {
getServer().getPluginManager().registerEvents(new Child(this), this);
}
} class Child implements Listener {
private final JavaPlugin parentPlugin;
public Child(JavaPlugin pl) {
parentPlugin = pl;
public class LocationStore {
private static final HashMap<UUID, Location> SPECTATOR_POS = new HashMap<>();
public static Location getLoc(Player player) {
return SPECTATOR_POS.get(player.getUniqueId());
}
public static void setLoc(Player player) {
/**
* Guesses the inner classes from class nodes
*/
public void fixInnerClasses() {
Map<String, InnerClassNode> splitInner = new HashMap<>();
Set<String> enums = new HashSet<>();
Map<String, List<InnerClassNode>> parents = new HashMap<>();
Map<String, ClassNode> classNodes = new HashMap<>();
@Geolykt
Geolykt / MMFCodeModifier.java
Created June 16, 2021 12:02
Starloader ASM mod that enables the use of .ogg and .wav files. Tested with Galimulator 4.8 to Galimulator 4.9-beta.7
package de.geolykt.moremusic;
import java.lang.reflect.Method;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
@Geolykt
Geolykt / Empire.j
Created July 20, 2021 18:10
Bytecode and Documentation of snoddasmannen/galimulator/Empire.S()Ljava/lang/String; (Galimulator Version 4.9-beta.7)
DEFINE PUBLIC S()Ljava/lang/String;
A:
LDC ""
ASTORE 1
ALOAD this
INVOKEVIRTUAL snoddasmannen/galimulator/Empire.getName()Ljava/lang/String;
LDC " "
INVOKEVIRTUAL java/lang/String.split(Ljava/lang/String;)[Ljava/lang/String;
ASTORE 2 // save Array
ALOAD 2 // obtain array length
@Geolykt
Geolykt / Oaktree.java
Created July 23, 2021 13:33
A failed attempt at solving some <undefinedtype> mentions. Perhaps one day someone will get this to work, which is why I pushed it here. However it is more likely that it just does not work and the idea was super dumb
/**
* Guesses anonymous inner classes by checking whether they have a synthetic field and if they
* do whether they are referenced only by a single "parent" class.
* Note: this method is VERY aggressive when it comes to adding inner classes, sometimes it adds
* inner classes on stuff where it wouldn't belong. This means that useage of this method should
* be done wiseley. This method will do some damage even if it does no good.
*
* @param doLog whether to perfom any logging via System.out
*/
@Geolykt
Geolykt / ServerHandler.java
Created September 4, 2021 13:55
old ServerHandler code before rewrite to support large packets
package de.geolykt.galimp.prototype.server;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.geolykt.galimp.prototype.Side;
import de.geolykt.galimp.prototype.common.PacketProccessor;
import de.geolykt.galimp.prototype.server.packets.processing.JoinPacketProcessor;
@Geolykt
Geolykt / setJavaHome.sh
Created October 30, 2021 12:14
Set the Java Home based on the java defined by alternatives. Not the most efficent approach, but works on my machine (TM)
export JAVA_HOME=`alternatives --display java | grep "link currently points to" | tr ' ' '\n' | grep -o -P "[\\/].+" | sed -e "s/bin\/java//"`
@Geolykt
Geolykt / gist:d456a7c2aa53b6d8582cf19f9d3d8d08
Created October 30, 2021 19:23
Quiltflower decompile issues
WARN: Method parseOptions ([Ljava/lang/String;)[Ljava/lang/String; in class org/junit/runner/JUnitCommandLineParseResult couldn't be decompiled.
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.base/java.util.Objects.checkIndex(Objects.java:359)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at org.jetbrains.java.decompiler.modules.decompiler.InlineSingleBlockHelper.inlineBlock(InlineSingleBlockHelper.java:50)
at org.jetbrains.java.decompiler.modules.decompiler.InlineSingleBlockHelper.inlineSingleBlocksRec(InlineSingleBlockHelper.java:37)
at org.jetbrains.java.decompiler.modules.decompiler.InlineSingleBlockHelper.inlineSingleBlocksRec(InlineSingleBlockHelper.java:29)
@Geolykt
Geolykt / CoordinatesProcessor.java
Created April 2, 2022 19:37
Tool to aid the placement of structures on sites such as r/place. Syntax: `java CoordinatesProcessor.java <inputFile> <leftX> <upperY>`
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.font.GlyphVector;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class CoordinatesProcessor {