forked from Minecraft/PluginAPI
Update dependencies and IDE suggestions (#8)
Update dependencies and IDE suggestions Signed-off-by: Etzelia <etzelia@hotmail.com> Reviewed-on: https://git.etztech.xyz/Minecraft/PluginAPI/pulls/8 Reviewed-by: ZeroHD <joey@ahines.net>master
parent
ca49c89440
commit
787a47108a
6
pom.xml
6
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>xyz.etztech</groupId>
|
||||
<artifactId>plugin-api</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.0.7</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -30,12 +30,12 @@
|
|||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<version>3.4.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.197</version>
|
||||
<version>1.4.200</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ import java.sql.SQLException;
|
|||
* A class to initialize an H2 database and retrieve connections
|
||||
*/
|
||||
public class DataSource {
|
||||
private HikariConfig config = new HikariConfig();
|
||||
private HikariDataSource dataSource;
|
||||
private final HikariDataSource dataSource;
|
||||
|
||||
/** Create a data source for a plugin
|
||||
* @param plugin The plugin using this database. Used for creation purposes.
|
||||
*/
|
||||
public DataSource(JavaPlugin plugin) {
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl("jdbc:h2:" + plugin.getDataFolder().getAbsolutePath() + "/" + plugin.getName().toLowerCase());
|
||||
config.setDriverClassName("org.h2.Driver");
|
||||
dataSource = new HikariDataSource(config);
|
||||
|
|
|
@ -21,10 +21,10 @@ import java.util.List;
|
|||
public class MultipartUtility {
|
||||
private final String boundary;
|
||||
private static final String LINE_FEED = "\r\n";
|
||||
private HttpURLConnection httpConn;
|
||||
private String charset;
|
||||
private OutputStream outputStream;
|
||||
private PrintWriter writer;
|
||||
private final HttpURLConnection httpConn;
|
||||
private final String charset;
|
||||
private final OutputStream outputStream;
|
||||
private final PrintWriter writer;
|
||||
|
||||
/**
|
||||
* This constructor initializes a new HTTP POST request where content type
|
||||
|
@ -59,10 +59,10 @@ public class MultipartUtility {
|
|||
* @param value field value
|
||||
*/
|
||||
public void addFormField(String name, String value) {
|
||||
writer.append("--" + boundary).append(LINE_FEED);
|
||||
writer.append("Content-Disposition: form-data; name=\"" + name + "\"")
|
||||
writer.append("--").append(boundary).append(LINE_FEED);
|
||||
writer.append("Content-Disposition: form-data; name=\"").append(name).append("\"")
|
||||
.append(LINE_FEED);
|
||||
writer.append("Content-Type: text/plain; charset=" + charset).append(
|
||||
writer.append("Content-Type: text/plain; charset=").append(charset).append(
|
||||
LINE_FEED);
|
||||
writer.append(LINE_FEED);
|
||||
writer.append(value).append(LINE_FEED);
|
||||
|
@ -78,14 +78,10 @@ public class MultipartUtility {
|
|||
public void addFilePart(String fieldName, File uploadFile)
|
||||
throws IOException {
|
||||
String fileName = uploadFile.getName();
|
||||
writer.append("--" + boundary).append(LINE_FEED);
|
||||
writer.append(
|
||||
"Content-Disposition: form-data; name=\"" + fieldName
|
||||
+ "\"; filename=\"" + fileName + "\"")
|
||||
writer.append("--").append(boundary).append(LINE_FEED);
|
||||
writer.append("Content-Disposition: form-data; name=\"").append(fieldName).append("\"; filename=\"").append(fileName).append("\"")
|
||||
.append(LINE_FEED);
|
||||
writer.append(
|
||||
"Content-Type: "
|
||||
+ URLConnection.guessContentTypeFromName(fileName))
|
||||
writer.append("Content-Type: ").append(URLConnection.guessContentTypeFromName(fileName))
|
||||
.append(LINE_FEED);
|
||||
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
|
||||
writer.append(LINE_FEED);
|
||||
|
@ -110,7 +106,7 @@ public class MultipartUtility {
|
|||
* @param value - value of the header field
|
||||
*/
|
||||
public void addHeaderField(String name, String value) {
|
||||
writer.append(name + ": " + value).append(LINE_FEED);
|
||||
writer.append(name).append(": ").append(value).append(LINE_FEED);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
|
@ -123,7 +119,7 @@ public class MultipartUtility {
|
|||
StringBuilder response = new StringBuilder();
|
||||
|
||||
//writer.append(LINE_FEED).flush();
|
||||
writer.append("--" + boundary + "--").append(LINE_FEED);
|
||||
writer.append("--").append(boundary).append("--").append(LINE_FEED);
|
||||
writer.close();
|
||||
|
||||
// checks server's status code first
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Response {
|
|||
private Boolean status;
|
||||
private String message;
|
||||
|
||||
private static Logger log = Logger.getLogger("Minecraft");
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
/**
|
||||
* @param httpResponse A JSON array e.g. multiple results from one call
|
||||
|
|
Loading…
Reference in New Issue