This commit is contained in:
sky 2020-05-09 15:23:41 +08:00
parent 6ef32eb241
commit 64f7dd2817
5 changed files with 51 additions and 20 deletions

View File

@ -6,5 +6,5 @@ FETCH-LOCALE-ERROR: 'Failed fetching language{0}'
SEND-LOCALE-ERROR: 'Failed sending language{0}'
LOCALE-ERROR-REASON: 'Reason{0}'
MISSING-ARGUMENT: 'Missing argument {0}'
DEPENDENCY-DOWNLOAD-START: ' Download {0} library'
DEPENDENCY-LOAD-FAIL: ' The requested library file {1} by {0} failed to load'
DEPENDENCY-DOWNLOAD-START: 'Loading {0}'
DEPENDENCY-LOAD-FAIL: 'The requested library file {1} by {0} failed to load'

View File

@ -25,15 +25,42 @@ import java.util.concurrent.Executors;
* 注意与 TabooLib4.x 版本的兼容
* 可能存在同时运行的情况
*/
@Dependency(maven = "org.slf4j:slf4j-api:1.7.25", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/org.slf4j-slf4j-api-1.7.25.jar")
@Dependency(maven = "com.zaxxer:HikariCP:3.1.0", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/com.zaxxer-HikariCP-3.1.0.jar")
@Dependency(maven = "org.scala-lang:scala-library:2.12.8", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/scala-library-2.12.8.jar")
@Dependency(maven = "org:kotlinlang:kotlin-stdlib:1.3.50", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-stdlib-1.3.50.jar")
@Dependency(maven = "org:kotlinlang:kotlin-stdlib-jdk7:1.3.50", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-stdlib-jdk7.jar")
@Dependency(maven = "org:kotlinlang:kotlin-stdlib-jdk8:1.3.50", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-stdlib-jdk8.jar")
@Dependency(maven = "org:kotlinlang:kotlin-reflect:1.3.50", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-reflect.jar")
@Dependency(maven = "org:kotlinlang:kotlin-test:1.3.50", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-test.jar")
@Dependency(maven = "com.google.inject:guice:4.2.2", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/guice-4.2.2.jar")
@Dependency(
maven = "org.slf4j:slf4j-api:1.7.25",
url = "http://repo.ptms.ink/repository/maven-public/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/org.slf4j-slf4j-api-1.7.25.jar"
)
@Dependency(
maven = "com.zaxxer:HikariCP:3.1.0",
url = "http://repo.ptms.ink/repository/maven-releases/com/zaxxer/HikariCP/3.1.0/HikariCP-3.1.0.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/com.zaxxer-HikariCP-3.1.0.jar"
)
@Dependency(
maven = "org.scala-lang:scala-library:2.12.8",
url = "http://repo.ptms.ink/repository/maven-public/org/scala-lang/scala-library/2.12.8/scala-library-2.12.8.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/scala-library-2.12.8.jar"
)
@Dependency(
maven = "org.kotlinlang:kotlin-stdlib:1.3.50",
url = "http://repo.ptms.ink/repository/maven-releases/org/kotlinlang/kotlin-stdlib/1.3.50/kotlin-stdlib-1.3.50.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-stdlib-1.3.50.jar"
)
@Dependency(
maven = "org.kotlinlang:kotlin-stdlib-jdk7:1.3.50",
url = "http://repo.ptms.ink/repository/maven-releases/org/kotlinlang/kotlin-stdlib-jdk7/1.3.50/kotlin-stdlib-jdk7-1.3.50.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-stdlib-jdk7.jar"
)
@Dependency(
maven = "org.kotlinlang:kotlin-stdlib-jdk8:1.3.50",
url = "http://repo.ptms.ink/repository/maven-releases/org/kotlinlang/kotlin-stdlib-jdk8/1.3.50/kotlin-stdlib-jdk8-1.3.50.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-stdlib-jdk8.jar"
)
@Dependency(
maven = "org.kotlinlang:kotlin-reflect:1.3.50",
url = "http://repo.ptms.ink/repository/maven-releases/org/kotlinlang/kotlin-reflect/1.3.50/kotlin-reflect-1.3.50.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-reflect.jar"
)
@Dependency(
maven = "org.kotlinlang:kotlin-test:1.3.50",
url = "http://repo.ptms.ink/repository/maven-releases/org/kotlinlang/kotlin-test/1.3.50/kotlin-test-1.3.50.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/kotlin-test.jar"
)
@Dependency(
maven = "com.google.inject:guice:4.2.2",
url = "http://repo.ptms.ink/repository/maven-releases/com/google/inject/guice/4.2.2/guice-4.2.2.jar;" + "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/guice-4.2.2.jar"
)
public class TabooLib {
private static TabooLib inst = new TabooLib();

View File

@ -56,7 +56,7 @@ public class TDependency {
}
private static boolean downloadMaven(String url, String groupId, String artifactId, String version, File target, String dl) {
TabooLib.getLogger().info(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("DEPENDENCY-DOWNLOAD-START"), target.getName()));
System.out.println("[TabooLib] " + Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("DEPENDENCY-DOWNLOAD-START"), target.getName()));
return Files.downloadFile(dl.length() == 0 ? url + "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar" : dl, Files.file(target));
}
}

View File

@ -15,10 +15,14 @@ public class TDependencyInjector {
public static void inject(Plugin plugin, Class<?> clazz) {
if (clazz.equals(TabooLib.class)) {
for (Dependency dependency : TabooLib.class.getAnnotationsByType(Dependency.class)) {
try {
TDependency.requestLib(dependency.maven(), dependency.mavenRepo(), dependency.url());
} catch (Throwable t) {
t.printStackTrace();
for (String url : dependency.url().split(";")) {
try {
if (TDependency.requestLib(dependency.maven(), dependency.mavenRepo(), url)) {
break;
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}
} else {

View File

@ -75,7 +75,7 @@ public class Items {
public static Material asMaterial(String args) {
try {
Material material = Material.getMaterial(args.toUpperCase());
return material != null ? material : Material.getMaterial(Integer.valueOf(args));
return material != null ? material : Material.getMaterial(Integer.parseInt(args));
} catch (Exception e) {
return Material.STONE;
}
@ -84,7 +84,7 @@ public class Items {
public static Color asColor(String color) {
try {
String[] v = color.split("-");
return Color.fromBGR(Integer.valueOf(v[0]), Integer.valueOf(v[1]), Integer.valueOf(v[2]));
return Color.fromBGR(Integer.parseInt(v[0]), Integer.parseInt(v[1]), Integer.parseInt(v[2]));
} catch (Exception e) {
return Color.fromBGR(0, 0, 0);
}
@ -101,7 +101,7 @@ public class Items {
public static Enchantment asEnchantment(String enchant) {
try {
Enchantment enchantment = Enchantment.getByName(enchant);
return enchantment != null ? enchantment : Enchantment.getById(Integer.valueOf(enchant));
return enchantment != null ? enchantment : Enchantment.getById(Integer.parseInt(enchant));
} catch (Exception e) {
return null;
}
@ -110,7 +110,7 @@ public class Items {
public static PotionEffectType asPotionEffectType(String potion) {
try {
PotionEffectType type = PotionEffectType.getByName(potion);
return type != null ? type : PotionEffectType.getById(Integer.valueOf(potion));
return type != null ? type : PotionEffectType.getById(Integer.parseInt(potion));
} catch (Exception e) {
return null;
}