From 512b621a7a2db5418536573a50de648e922961db Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 3 Mar 2019 16:46:20 +0000 Subject: [PATCH] Refactor Dependency class a bit --- .../common/dependencies/Dependency.java | 40 ++++++------------- .../dependencies/relocation/Relocation.java | 6 --- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index 5f906ba90..a74e1eb8a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -109,10 +109,8 @@ public enum Dependency { "okhttp", "3.12.1", "B8PYLKfq9HIvALLagH3Hhg9haa5gz+3PXUAhj5CICkY=", - Relocation.allOf( - Relocation.of(RelocationHelper.OKHTTP3_STRING, RelocationHelper.OKHTTP3_STRING), - Relocation.of(RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING) - ) + Relocation.of(RelocationHelper.OKHTTP3_STRING, RelocationHelper.OKHTTP3_STRING), + Relocation.of(RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING) ), COMMODORE( "me{}lucko", @@ -182,21 +180,17 @@ public enum Dependency { "mongo-java-driver", "3.9.1", "mxKxkvmYluxV+Hdn57uyt+MjjSQUsFjxFw9tjhx0bm4=", - Relocation.allOf( - Relocation.of("mongodb", "com{}mongodb"), - Relocation.of("bson", "org{}bson") - ) + Relocation.of("mongodb", "com{}mongodb"), + Relocation.of("bson", "org{}bson") ), JEDIS( "redis.clients", "jedis", "2.10.1", "Pp7msE2yJk5QRF9ASqM/6glX95xsnrwkm9BfN37vLI4=", - Relocation.allOf( - Relocation.of("jedis", "redis{}clients{}jedis"), - Relocation.of("jedisutil", "redis{}clients{}util"), - Relocation.of("commonspool2", "org{}apache{}commons{}pool2") - ) + Relocation.of("jedis", "redis{}clients{}jedis"), + Relocation.of("jedisutil", "redis{}clients{}util"), + Relocation.of("commonspool2", "org{}apache{}commons{}pool2") ), COMMONS_POOL_2( "org.apache.commons", @@ -238,10 +232,8 @@ public enum Dependency { "configurate-hocon", "3.5", "sOym1KPmQylGSfk90ZFqobuvoZfEWb7XMmMBwbHuxFw=", - Relocation.allOf( - Relocation.of("configurate", "ninja{}leaping{}configurate"), - Relocation.of("hocon", "com{}typesafe{}config") - ) + Relocation.of("configurate", "ninja{}leaping{}configurate"), + Relocation.of("hocon", "com{}typesafe{}config") ), HOCON_CONFIG( "com{}typesafe", @@ -255,10 +247,8 @@ public enum Dependency { "configurate-toml", "3.5", "U8p0XSTaNT/uebvLpO/vb6AhVGQDYiZsauSGB9zolPU=", - Relocation.allOf( - Relocation.of("configurate", "ninja{}leaping{}configurate"), - Relocation.of("toml4j", "com{}moandjiezana{}toml") - ) + Relocation.of("configurate", "ninja{}leaping{}configurate"), + Relocation.of("toml4j", "com{}moandjiezana{}toml") ), TOML4J( "com{}moandjiezana{}toml", @@ -278,14 +268,10 @@ public enum Dependency { private static final String MAVEN_FORMAT = "%s/%s/%s/%s-%s.jar"; Dependency(String groupId, String artifactId, String version, String checksum) { - this(groupId, artifactId, version, checksum, ImmutableList.of()); + this(groupId, artifactId, version, checksum, new Relocation[0]); } - Dependency(String groupId, String artifactId, String version, String checksum, Relocation relocation) { - this(groupId, artifactId, version, checksum, ImmutableList.of(relocation)); - } - - Dependency(String groupId, String artifactId, String version, String checksum, List relocations) { + Dependency(String groupId, String artifactId, String version, String checksum, Relocation... relocations) { String path = String.format(MAVEN_FORMAT, rewriteEscaping(groupId).replace(".", "/"), rewriteEscaping(artifactId), diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/relocation/Relocation.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/relocation/Relocation.java index ae8dfe798..7197c148b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/relocation/Relocation.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/relocation/Relocation.java @@ -25,8 +25,6 @@ package me.lucko.luckperms.common.dependencies.relocation; -import java.util.Arrays; -import java.util.List; import java.util.Objects; public final class Relocation { @@ -36,10 +34,6 @@ public final class Relocation { return new Relocation(pattern.replace("{}", "."), RELOCATION_PREFIX + id); } - public static List allOf(Relocation... relocations) { - return Arrays.asList(relocations); - } - private final String pattern; private final String relocatedPattern;