Skip to content
That crap between the bricks
Branch: master
Clone or download
Latest commit db089ce Mar 25, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
javadoc 44 Mar 25, 2019
scripts 1.0.1 Mar 1, 2019
.gitignore Init git Feb 26, 2019 Update Feb 27, 2019
stylesheet.css Release Feb 27, 2019


That crap between the bricks

I depend on Mortar & cant auto-download Mortar without Mortar...

Because plugins depend on MortarPlugin you may have some class loading issues when enabling. To work around this, simply add this anywhere in your main plugin class.

What this does

  • Checks if mortar is installed already
  • If not, downloads Mortar and force-loads it

Mortar will be enabled before your plugin is enabled.

static{try{URL url = new URL("");
File plugins = new File("plugins");Boolean foundMortar = false;for(File i : plugins.listFiles())
{if(i.isFile() && i.getName().endsWith(".jar")){ZipFile file = new ZipFile(i);try{
Enumeration<? extends ZipEntry> entries = file.entries();while(entries.hasMoreElements())
{ZipEntry entry = entries.nextElement();if("plugin.yml".equals(entry.getName())){
InputStream in = file.getInputStream(entry);
PluginDescriptionFile pdf = new PluginDescriptionFile(in);if(pdf.getMain()
.equals("mortar.bukkit.plugin.MortarAPIPlugin")){foundMortar = true;break;}}}}catch(Throwable ex)
.println("Cannot find mortar. Attempting to download...");try{HttpURLConnection con = 
(HttpURLConnection)url.openConnection(); HttpURLConnection.setFollowRedirects(false);
con.setConnectTimeout(10000);con.setReadTimeout(10000);InputStream in = con.getInputStream();
File mortar = new File("plugins/Mortar.jar");FileOutputStream fos = 
new FileOutputStream(mortar);byte[] buf = new byte[16819];int r = 0;
while((r = != -1){fos.write(buf, 0, r);}fos.close();in.close();
con.disconnect();System.out.println("Mortar has been downloaded. Installing...");
Bukkit.getPluginManager().loadPlugin(mortar);}catch(Throwable e){System.out
.println("Failed to download mortar! Please download it from " + url.toString()
);}}}catch(Throwable e){e.printStackTrace();}}
You can’t perform that action at this time.