Skip to content

Commit

Permalink
Merge pull request #119 from TeamKun/develop
Browse files Browse the repository at this point in the history
v3.0.4 リリース用
  • Loading branch information
PeyaPeyaPeyang authored Mar 23, 2023
2 parents 92e1588 + c37ac7b commit 48203ff
Show file tree
Hide file tree
Showing 65 changed files with 527 additions and 330 deletions.
8 changes: 4 additions & 4 deletions KPMAlias/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.kunlab.kpm</groupId>
<artifactId>TeamKunPluginManager</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -22,19 +22,19 @@
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMCommon</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMModels</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMResolver</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.kunlab.kpm.alias.interfaces.Alias;

@Value
class AliasRecord implements Alias
class AliasImpl implements Alias
{
@NotNull
String alias;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public Alias getQueryByAlias(String alias)
if (row == null)
return null;

return new AliasRecord(
return new AliasImpl(
row.getString("alias"),
row.getString("query"),
row.getString("source_id")
Expand Down
2 changes: 1 addition & 1 deletion KPMCommon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.kunlab.kpm</groupId>
<artifactId>TeamKunPluginManager</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public static StatusCode valueOf(int code)
{
return Arrays.stream(values()).parallel()
.filter(v -> v.code == code)
.filter(v -> !v.name().startsWith("RANGE_"))
.findFirst()
.orElse(UNKNOWN);
}
Expand Down
54 changes: 54 additions & 0 deletions KPMCommon/src/main/java/org/kunlab/kpm/utils/PluginUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
import org.bukkit.plugin.java.PluginClassLoader;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.Iterator;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
Expand All @@ -24,6 +32,7 @@ public class PluginUtil
{

private static final Method pluginGetFile;
private static final int HASH_BUFFER_SIZE = 1024;

static
{
Expand Down Expand Up @@ -92,4 +101,49 @@ public static PluginDescriptionFile loadDescription(File file) throws InvalidDes
}
}

@SuppressWarnings("StatementWithEmptyBody")
public static String getHash(Path path, String algo)
{
MessageDigest md;
try
{
md = MessageDigest.getInstance(algo);
}
catch (NoSuchAlgorithmException e)
{
return "<No such algorithm: " + algo + ">";
}

try (FileInputStream fis = new FileInputStream(path.toFile());
DigestInputStream dis = new DigestInputStream(fis, md))
{
byte[] buffer = new byte[HASH_BUFFER_SIZE];
while (dis.read(buffer) != -1)
{
}

byte[] digest = md.digest();
StringBuilder sb = new StringBuilder();
for (byte b : digest)
sb.append(String.format("%02x", b));

return sb.toString();
}
catch (IOException e)
{
return "<IOException thrown: " + e.getMessage() + ">";
}
}

public static void forceDelete(Path path) throws IOException
{
if (Files.isDirectory(path))
try (Stream<Path> stream = Files.list(path))
{
Iterator<Path> iterator = stream.iterator();
while (iterator.hasNext())
forceDelete(iterator.next());
}
Files.delete(path);
}
}
20 changes: 10 additions & 10 deletions KPMDaemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>TeamKunPluginManager</artifactId>
<groupId>org.kunlab.kpm</groupId>
<version>3.0.3</version>
<version>3.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -111,55 +111,55 @@
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMModels</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMCommon</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMResolver</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMAlias</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMMeta</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMHooks</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMInfo</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMPluginInstaller</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMTasks</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions KPMHooks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.kunlab.kpm</groupId>
<artifactId>TeamKunPluginManager</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -22,13 +22,13 @@
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMModels</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMCommon</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
14 changes: 10 additions & 4 deletions KPMInfo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.kunlab.kpm</groupId>
<artifactId>TeamKunPluginManager</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -22,19 +22,25 @@
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMCommon</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMModels</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMHooks</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMResolver</artifactId>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
11 changes: 6 additions & 5 deletions KPMInfo/src/main/java/org/kunlab/kpm/kpminfo/KPMInfoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.kunlab.kpm.hook.HookRecipientListImpl;
import org.kunlab.kpm.interfaces.KPMRegistry;
import org.kunlab.kpm.hook.interfaces.HookRecipientList;
import org.kunlab.kpm.resolver.QueryContext;
import org.kunlab.kpm.interfaces.KPMRegistry;
import org.kunlab.kpm.resolver.QueryContextParser;
import org.kunlab.kpm.resolver.interfaces.QueryContext;
import org.kunlab.kpm.versioning.Version;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
Expand Down Expand Up @@ -44,7 +45,7 @@ private static KPMInformationFile loadFromMap(@NotNull KPMRegistry registry, Map
boolean allowManuallyInstall = parseAllowManuallyInstall(map); // Parse allowManuallyInstall [optional: true]


return new KPMInformationFile(version, updateQuery, hooks, recipes, dependencies, allowManuallyInstall);
return new KPMInformationFileImpl(version, updateQuery, hooks, recipes, dependencies, allowManuallyInstall);
}

@NotNull
Expand Down Expand Up @@ -72,7 +73,7 @@ private static QueryContext parseUpdateQuery(Map<?, ?> map) throws InvalidInform
if (updateQuery.isEmpty())
throw new InvalidInformationFileException("Update query is empty.");

return QueryContext.fromString(updateQuery);
return QueryContextParser.fromString(updateQuery);
}

@NotNull
Expand Down Expand Up @@ -146,7 +147,7 @@ private static Map<String, QueryContext> parseDependencies(Map<?, ?> map) throws
String value = (String) entry.getValue();
try
{
result.put(key, QueryContext.fromString(value));
result.put(key, QueryContextParser.fromString(value));
}
catch (IllegalArgumentException e)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.kunlab.kpm.kpminfo;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Value;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.kunlab.kpm.hook.interfaces.HookRecipientList;
import org.kunlab.kpm.resolver.interfaces.QueryContext;
import org.kunlab.kpm.versioning.Version;

import java.util.Map;

@Value
@AllArgsConstructor(access = AccessLevel.PACKAGE)
class KPMInformationFileImpl implements KPMInformationFile
{
@NotNull
Version kpmVersion;
@Nullable
QueryContext updateQuery;
@NotNull
HookRecipientList hooks;
@NotNull
String[] recipes;
@NotNull
Map<String, QueryContext> dependencies;
boolean allowManuallyInstall;
}
8 changes: 4 additions & 4 deletions KPMMeta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.kunlab.kpm</groupId>
<artifactId>TeamKunPluginManager</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -22,19 +22,19 @@
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMCommon</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMModels</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kunlab.kpm</groupId>
<artifactId>KPMResolver</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
14 changes: 14 additions & 0 deletions KPMMeta/src/main/java/org/kunlab/kpm/meta/DependencyNodeImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.kunlab.kpm.meta;

import lombok.Value;
import org.kunlab.kpm.meta.interfaces.DependencyNode;

@Value
class DependencyNodeImpl implements DependencyNode
{
String plugin;

String dependsOn;

DependType dependType;
}
Loading

0 comments on commit 48203ff

Please sign in to comment.