Skip to content

Commit

Permalink
Adds support to 1.17
Browse files Browse the repository at this point in the history
Adds ManagerDirector#isPlaceholderAPIEnabled
  • Loading branch information
anjoismysign committed Oct 22, 2023
1 parent 8c6b3c3 commit 0806ee7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ci-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.20</version>
<version>1.697.21</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion local-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.20</version>
<version>1.697.21</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.20</version>
<version>1.697.21</version>
<packaging>pom</packaging>

<properties>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/us/mytheria/bloblib/managers/ManagerDirector.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,23 @@ public <T extends BlobSerializable> void addListenerBlobSerializableManager(Stri
* @param consumer The consumer that will consume the expansion
*/
public void instantiateBlobPHExpansion(String identifier, Consumer<BlobPHExpansion> consumer) {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") == null) {
getPlugin().getAnjoLogger().log("PlaceholderAPI not found, not registering PlaceholderAPI expansion for " + getPlugin().getName());
if (!isPlaceholderAPIEnabled()) {
getPlugin().getAnjoLogger().log("PlaceholderAPI not found, not instantiating PlaceholderAPI expansion for " + getPlugin().getName());
return;
}
BlobPHExpansion expansion = new BlobPHExpansion(getPlugin(), identifier);
consumer.accept(expansion);
}

/**
* Checks whether PlaceholderAPI is enabled.
*
* @return Whether PlaceholderAPI is enabled.
*/
public boolean isPlaceholderAPIEnabled() {
return Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
}

/**
* Adds a wallet owner manager to the director.
*
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/us/mytheria/bloblib/utilities/ResourceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ public static void writeNewValues(File existingFile, YamlConfiguration updateYam
Set<String> keys = updateYamlConfiguration.getConfigurationSection("").getKeys(true);
keys.forEach(key -> {
if (!updateYamlConfiguration.isConfigurationSection(key)) {
List<String> comments = updateYamlConfiguration.getComments(key);
List<String> inLine = updateYamlConfiguration.getInlineComments(key);
if (comments.size() > 0)
existingYamlConfig.setComments(key, comments);
if (inLine.size() > 0)
existingYamlConfig.setInlineComments(key, inLine);
try {
List<String> comments = updateYamlConfiguration.getComments(key);
List<String> inLine = updateYamlConfiguration.getInlineComments(key);
if (comments.size() > 0)
existingYamlConfig.setComments(key, comments);
if (inLine.size() > 0)
existingYamlConfig.setInlineComments(key, inLine);
} catch (NoSuchMethodError ignored) {
}
// if it's not a section, it's a value
if (existingYamlConfig.contains(key)) return;
}
Expand Down

0 comments on commit 0806ee7

Please sign in to comment.