package net.engin33r.luaspigot.lua.type;

import lombok.RequiredArgsConstructor;
import net.engin33r.luaspigot.lua.Function;
import net.engin33r.luaspigot.lua.WeakType;
import net.engin33r.luaspigot.lua.annotation.MetaMethodDef;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs;

import java.util.UUID;

/**
 * Weak type to definitely represent UUIDs.
 */
@RequiredArgsConstructor
public class LuaUUID extends WeakType {
    private final UUID uuid;
    private static LuaValue typeMetatable = LuaValue.tableOf();

    public LuaUUID(String uuid) {
        this.uuid = UUID.fromString(uuid);

        registerMetaMethod("eq", new Function() {
            @Override
            public String getName() {
                return null;
            }

            @Override
            public Varargs call(Varargs args) {
                return null;
            }
        });
    }

    @Override
    public String getName() {
        return "UUID";
    }

    @Override
    public String toLuaString() {
        return "UUID: "+uuid.toString();
    }

    public UUID getUUID() {
        return this.uuid;
    }

    @MetaMethodDef(name = "__eq")
    public Varargs equals(Varargs arg) {
        LuaUUID uuid2 = (LuaUUID) arg.checktable(1);
        return LuaValue.valueOf(this.uuid.equals(uuid2.getUUID()));
    }

    @Override
    protected LuaValue getMetatable() {
        return typeMetatable;
    }
}

@@ -78,52 +78,8 @@
 or;%0A
-import net.engin33r.luaspigot.lua.Function;%0A
 impo
@@ -553,288 +553,8 @@
 id);
-%0A%0A        registerMetaMethod(%22eq%22, new Function() %7B%0A            @Override%0A            public String getName() %7B%0A                return null;%0A            %7D%0A%0A            @Override%0A            public Varargs call(Varargs args) %7B%0A                return null;%0A            %7D%0A        %7D);
 %0A   

Remove dead code