/report

Upload bukkit logs + plugin logs to pastebin.com

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

Report-API

Build Status License Bukkit

Upload server logs & plugin configurations for bug reports.

Installation

Add this to your pom.xml:

<dependency>
  <groupId>com.carlgo11</groupId>
  <artifactId>report</artifactId>
  <version>1.1</version>
</dependency>

Run via command line:

mvn install

import the Report class in your own class:

import com.carlgo11.report.Report;

Go to Pastebin.com and create an account if you haven't already.
Then go to Pastebin API, retrieve your API key and optionally your User Key.

Plugin dependency

As your plugin will have to load after the Report-API has finished loading it's a good idea to make that clear in the plugin.yml of your plugin. This can be done through several ways.

Hard dependency

The first one is to require Report-API to be present for your plugin do load:

depend:
  - report-api

Soft dependency

If you'd rather have the report feature as an optional functionality you can use the soft depend tag:

softdepend:
  - report-api

This way the server will try and load Report-API before your own plugin if Report-API is present in the plugins folder. If not, it will just load your plugin normally.

Usage

To generate a report, call the Report class like this:

String api_key = ""; //Pastebin API key
String user_key = ""; //Pastebin User key (can be left blank)

Report report = new Report(plugin, user_key, api_key); //Call Report class
report.makeReport(); //Send the data away to Pastebin

You can then send the URL to the user who sent the request.

URL url = report.getURL(); //Get the Pastebin URL
sender.sendMessage("Give this URL to the support agent: " + URL.toString);

Optional code

It's a good idea to also check that the makeReport() function returns true and that the getURL() function returns a valid Pastebin URL.

String api_key = "";
String user_key = "";
try {
    Report report = new Report(plugin, user_key, api_key);
    if(report.makeReport()){
        URL url = report.getURL();
        if(url.toString().startsWith("https://pastebin.com/")){
            sender.sendMessage("Give this URL to the support agent: " + url.toString);
        }
    }
} catch (ClassNotFoundException e) {
    System.out.println("Report-API not installed!");
}

Compile locally

To compile Report-API locally you need:

  • Java JDK 8 or later
  • Apache Maven

Then run:

mvn install

Depending on your OS and Maven setup you might need to replace mvn with maven in the example above.

You should now have a Report-API JAR-file inside the target folder.