Skip to content

Commit

Permalink
Merge pull request #86 from PowerNetworkHub/1.10.8
Browse files Browse the repository at this point in the history
Release 1.10.8
  • Loading branch information
svenar-nl authored Sep 23, 2023
2 parents 82d9559 + 7e86553 commit c922a13
Show file tree
Hide file tree
Showing 62 changed files with 2,659 additions and 1,252 deletions.
38 changes: 17 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.svenar</groupId>
<artifactId>powerranks</artifactId>
<version>1.10.7</version>
<version>1.10.8</version>
<name>PowerRanks</name>
<description>An amazing permission plugin!</description>

Expand Down Expand Up @@ -64,7 +66,6 @@
</filters>
<artifactSet>
<includes>
<!-- <include>org.mongodb:mongo-java-driver</include> -->
<include>com.squareup.okhttp3:okhttp</include>
<include>com.squareup.okio:okio</include>
<include>org.jetbrains.kotlin:kotlin-stdlib</include>
Expand All @@ -77,10 +78,6 @@
</includes>
</artifactSet>
<relocations>
<!-- <relocation>
<pattern>com.mongodb</pattern>
<shadedPattern>${shade.basepattern}.mongodb</shadedPattern>
</relocation> -->
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>${shade.basepattern}.okhttp3</shadedPattern>
Expand Down Expand Up @@ -127,6 +124,12 @@
<outputDirectory>${testserver.location}</outputDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand All @@ -144,10 +147,6 @@
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- <repository>
<id>extendedclip-repo</id>
<url>http://repo.extendedclip.com/content/repositories/public/</url>
</repository> -->
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
Expand All @@ -156,23 +155,20 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- <repository>
<id>krypton</id>
<url>https://repo.kryptonmc.org/releases</url>
</repository> -->
<repository>
<id>svenar</id>
<url>https://svenar.nl/repo/</url>
</repository>
</repositories>

<dependencies>
<!-- <dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.10</version>
<type>jar</type>
</dependency> -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/nl/svenar/common/storage/PowerConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ public void setKV(String key, Object value) {
if (currentKey instanceof HashMap) {
currentKey = ((HashMap<String, Object>)currentKey).get(keySplit[i]);
} else {
if (((HashMap<String, Object>)currentKey).containsKey(keySplit[i])) {
throw new IllegalStateException("Key part '" + keySplit[i] + "' from '" + key + "' is not a map and has no children to be set!");
} else {
((HashMap<String, Object>)currentKey).put(keySplit[i], new HashMap<String, Object>());
currentKey = ((HashMap<String, Object>)currentKey).get(keySplit[i]);
if (currentKey != null) {
if (((HashMap<String, Object>)currentKey).containsKey(keySplit[i])) {
throw new IllegalStateException("Key part '" + keySplit[i] + "' from '" + key + "' is not a map and has no children to be set!");
} else {
((HashMap<String, Object>)currentKey).put(keySplit[i], new HashMap<String, Object>());
currentKey = ((HashMap<String, Object>)currentKey).get(keySplit[i]);
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,21 +384,25 @@ public void saveRanks() {
String serializedValue = gson.toJson(mapEntry.getValue());

try {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
// stmt.setString(3, serializedValue);
stmt.addBatch();
if (stmt != null) {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
// stmt.setString(3, serializedValue);
stmt.addBatch();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

try {
stmt.executeBatch();
this.connection.commit();
this.connection.setAutoCommit(true);
if (stmt != null) {
stmt.executeBatch();
this.connection.commit();
this.connection.setAutoCommit(true);
}
} catch (SQLException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -456,21 +460,25 @@ public void savePlayers() {
String serializedValue = gson.toJson(mapEntry.getValue());

try {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
// stmt.setString(3, serializedValue);
stmt.addBatch();
if (stmt != null) {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
// stmt.setString(3, serializedValue);
stmt.addBatch();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

try {
stmt.executeBatch();
this.connection.commit();
this.connection.setAutoCommit(true);
if (stmt != null) {
stmt.executeBatch();
this.connection.commit();
this.connection.setAutoCommit(true);
}
} catch (SQLException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -555,14 +563,16 @@ public void SQLInsert(String databaseName, String tableName, String key, String
}

try {
stmt.clearParameters();
stmt.setString(1, key);
stmt.setString(2, value);
stmt.addBatch();

stmt.executeBatch();
this.connection.commit();
this.connection.setAutoCommit(true);
if (stmt != null) {
stmt.clearParameters();
stmt.setString(1, key);
stmt.setString(2, value);
stmt.addBatch();

stmt.executeBatch();
this.connection.commit();
this.connection.setAutoCommit(true);
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,21 +394,25 @@ public void saveRanks() {
String serializedValue = gson.toJson(mapEntry.getValue());

try {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
stmt.setString(3, serializedValue);
stmt.addBatch();
if (stmt != null) {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
stmt.setString(3, serializedValue);
stmt.addBatch();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

try {
stmt.executeBatch();
this.ranksSQLConnection.commit();
this.ranksSQLConnection.setAutoCommit(true);
if (stmt != null) {
stmt.executeBatch();
this.ranksSQLConnection.commit();
this.ranksSQLConnection.setAutoCommit(true);
}
} catch (SQLException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -462,11 +466,13 @@ public void savePlayers() {
String serializedValue = gson.toJson(mapEntry.getValue());

try {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
stmt.setString(3, serializedValue);
stmt.addBatch();
if (stmt != null) {
stmt.clearParameters();
stmt.setString(1, dbKey);
stmt.setString(2, serializedValue);
stmt.setString(3, serializedValue);
stmt.addBatch();
}
// String query = SQLInsertOrUpdateKV(this.ranksFile.getName().split("\\.")[0],
// dbKey,
// serializedValue);
Expand All @@ -479,9 +485,11 @@ public void savePlayers() {
}

try {
stmt.executeBatch();
this.playersSQLConnection.commit();
this.playersSQLConnection.setAutoCommit(true);
if (stmt != null) {
stmt.executeBatch();
this.playersSQLConnection.commit();
this.playersSQLConnection.setAutoCommit(true);
}
} catch (SQLException e) {
e.printStackTrace();
}
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/nl/svenar/common/structure/PRPermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,26 @@

package nl.svenar.common.structure;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
* Structure to store permission data.
*
* @author svenar
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class PRPermission {

private String name;
private boolean value;

public PRPermission() {
name = "";
value = false;
this("", false);
}

public PRPermission(String name, boolean value) {
this.name = name;
this.value = value;
}

/**
Expand Down
Loading

0 comments on commit c922a13

Please sign in to comment.