copying source code from bukkit-workshop