Skip to content

Commit

Permalink
Adds ManagerDirector#detachAsset
Browse files Browse the repository at this point in the history
-package
  • Loading branch information
anjoismysign committed Sep 21, 2023
1 parent 8630ccb commit a5ac8f7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 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.692.0</version>
<version>1.693.0</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand All @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>${name}-${parent.version}</finalName>
<finalName>${project.name}-${project.parent.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 4 additions & 4 deletions 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.692.0</version>
<version>1.693.0</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand All @@ -20,7 +20,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>${name}-${parent.version}</finalName>
<finalName>${project.name}-${project.parent.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -108,11 +108,11 @@
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<version>${project.parent.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${testServer}/plugins/</outputDirectory>
<destFileName>${build.finalName}.jar</destFileName>
<destFileName>${project.build.finalName}.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
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.692.0</version>
<version>1.693.0</version>
<packaging>pom</packaging>

<!-- Repository configuration shared by child POMs -->
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/us/mytheria/bloblib/managers/ManagerDirector.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,35 @@ public BlobPlugin getPlugin() {
return plugin;
}

/**
* Will detach an embedded file/asset from the plugin jar to
* the corresponding directory
*
* @param fileName The name of the file to detach
* @param debug Whether to print debug messages
* @param path The path to the directory
* @return The ManagerDirector instance for method chaining
*/
public ManagerDirector detachAsset(String fileName, boolean debug, File path) {
Logger logger = getPlugin().getAnjoLogger();
File file = new File(path + "/" + fileName + ".yml");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
if (debug)
logger.debug(" asset " + fileName + ".yml was not detached");
e.printStackTrace();
return this;
}
}
ResourceUtil.updateYml(path, "/temp" + fileName + ".yml", fileName + ".yml", file, plugin);
boolean successful = MessageManager.loadAndRegisterYamlConfiguration(file, plugin);
if (debug && successful)
logger.debug(" asset " + fileName + ".yml successfully detached");
return this;
}

/**
* Will detach an embedded BlobMessage file/asset from the plugin jar to
* the corresponding directory in the plugin data folder.
Expand Down

0 comments on commit a5ac8f7

Please sign in to comment.