Skip to content

Utils for spigot coding. World tools. Runtime maven depends loader. Function and lambdas. Duck typing for Java.

License

Notifications You must be signed in to change notification settings

caoli5288/common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

common

License GPLv2.

Duck typing for Java

This is a duck typing implementation based on reflection and dynamic proxies with force methods access. Perhaps it can be used as a wrapper for reflect.

Examples

Call with parameter contravariant.

class Foo {
    void run() {
        println("I'm running")
    }
    void print(String msg) {
        println(msg)
    }
}

Foo foo = new Foo()
Runnable runnable = Types.asType(foo, Runnable.class)
runnable.run()// I'm running

Call with method name map.

class Foo {
    void run() {
        println("I'm running")
    }
}

Foo foo = new Foo()
Types.desc(Foo.class).map("run", Closeable.class, "close")
Types.asType(foo, Closeable.class).close()// I'm running

Compiled PlaceholderAPI string

10x faster than PlaceholderAPI.setPlaceholder(Player, String)

Examples

import com.mengcraft.util.CompiledStr
import org.bukkit.Bukkit

def compiled = new CompiledStr("My name is %player_name%")

println compiled.apply(Bukkit.getPlayerExact("HIM")) // My name is HIM

About

Utils for spigot coding. World tools. Runtime maven depends loader. Function and lambdas. Duck typing for Java.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages