+ update
This commit is contained in:
parent
9f9c2c9d06
commit
9b4448a033
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.skymc</groupId>
|
||||
<artifactId>TabooLib</artifactId>
|
||||
<version>4.72</version>
|
||||
<version>4.73</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -106,7 +106,7 @@ public class EagletTask {
|
||||
executorService.execute(download);
|
||||
long last = 0;
|
||||
do {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(500);
|
||||
// check the progress
|
||||
long progress = download.getCurrentProgress();
|
||||
// fire a new progress event
|
||||
@ -116,7 +116,7 @@ public class EagletTask {
|
||||
last = progress;
|
||||
// check complete
|
||||
} while (last != contentLength && !download.isComplete());
|
||||
// close the thread pool, release resources
|
||||
// close the thread pool, DoNotSupportMultipleThreadExceptionrelease resources
|
||||
executorService.shutdown();
|
||||
// change the running flag to false
|
||||
running = false;
|
||||
@ -137,7 +137,7 @@ public class EagletTask {
|
||||
}
|
||||
long last = 0;
|
||||
do {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(500);
|
||||
long progress = 0;
|
||||
// Collect download progress
|
||||
for (SplitDownload splitDownload : splitDownloads) {
|
||||
|
@ -12,7 +12,7 @@ public class TDependency {
|
||||
|
||||
// 阿里 http://maven.aliyun.com/nexus/content/groups/public
|
||||
// Maven Central
|
||||
public static final String MAVEN_REPO = "https://maven.aliyun.com/repository/central";
|
||||
public static final String MAVEN_REPO = "http://repo1.maven.org/maven2";
|
||||
|
||||
/**
|
||||
* 请求一个插件作为依赖,这个插件将会在所有已经添加的 Jenkins 仓库、Maven 仓库寻找
|
||||
@ -63,27 +63,18 @@ public class TDependency {
|
||||
new EagletTask()
|
||||
.url(link)
|
||||
.file(target)
|
||||
.setThreads(getDownloadPoolSize())
|
||||
.setOnError(event -> {
|
||||
})
|
||||
.setOnConnected(event -> TLocale.Logger.info("DEPENDENCY.DOWNLOAD-CONNECTED",
|
||||
String.join(":", new String[]{groupId, artifactId, version}), ProgressEvent.format(event.getContentLength())))
|
||||
.setOnProgress(event -> TLocale.Logger.info("DEPENDENCY.DOWNLOAD-PROGRESS",
|
||||
event.getSpeedFormatted(), event.getPercentageFormatted()))
|
||||
.setThreads(1)
|
||||
.setOnError(event -> event.getException().printStackTrace())
|
||||
.setOnConnected(event -> TLocale.Logger.info("DEPENDENCY.DOWNLOAD-CONNECTED", String.join(":", new String[] {groupId, artifactId, version}), ProgressEvent.format(event.getContentLength())))
|
||||
.setOnProgress(event -> TLocale.Logger.info("DEPENDENCY.DOWNLOAD-PROGRESS", event.getSpeedFormatted(), event.getPercentageFormatted()))
|
||||
.setOnComplete(event -> {
|
||||
if (event.isSuccess()) {
|
||||
TLocale.Logger.info("DEPENDENCY.DOWNLOAD-SUCCESS",
|
||||
String.join(":", new String[]{groupId, artifactId, version}));
|
||||
TLocale.Logger.info("DEPENDENCY.DOWNLOAD-SUCCESS", String.join(":", new String[] {groupId, artifactId, version}));
|
||||
} else {
|
||||
failed.set(true);
|
||||
TLocale.Logger.error("DEPENDENCY.DOWNLOAD-FAILED",
|
||||
String.join(":", new String[]{groupId, artifactId, version}), link, target.getName());
|
||||
TLocale.Logger.error("DEPENDENCY.DOWNLOAD-FAILED", String.join(":", new String[] {groupId, artifactId, version}), link, target.getName());
|
||||
}
|
||||
}).start().waitUntil();
|
||||
return !failed.get();
|
||||
}
|
||||
|
||||
private static int getDownloadPoolSize() {
|
||||
return Main.getInst().getConfig().getInt("DOWNLOAD-POOL-SIZE", 4);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class ItemUtils {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Material asMaterial(String args) {
|
||||
try {
|
||||
Material material = Material.getMaterial(args);
|
||||
Material material = Material.getMaterial(args.toUpperCase());
|
||||
return material != null ? material : Material.getMaterial(Integer.valueOf(args));
|
||||
} catch (Exception e) {
|
||||
return Material.STONE;
|
||||
|
@ -403,7 +403,12 @@ public enum EffLib {
|
||||
/**
|
||||
* 挥砍
|
||||
*/
|
||||
SWEEP_ATTACK("sweepAttack", 45, 9);
|
||||
SWEEP_ATTACK("sweepAttack", 45, 9),
|
||||
|
||||
/**
|
||||
* 不死图腾
|
||||
*/
|
||||
TOTEM("totem", 46, 11);
|
||||
|
||||
private static final Map<String, EffLib> NAME_MAP = new HashMap<>();
|
||||
private static final Map<Integer, EffLib> ID_MAP = new HashMap<>();
|
||||
|
@ -0,0 +1,73 @@
|
||||
package me.skymc.taboolib.particle.pack;
|
||||
|
||||
import com.ilummc.tlib.util.Strings;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.particle.EffLib;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author 坏黑
|
||||
* @Since 2019-01-11 17:37
|
||||
*/
|
||||
public class ParticleData {
|
||||
|
||||
private static final Pattern ITEM_PATTERN = Pattern.compile("(\\S+)\\((\\S+):(\\S+)\\)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private ParticleType particleType = ParticleType.NORMAL;
|
||||
private EffLib particle = EffLib.BARRIER;
|
||||
private EffLib.ParticleData particleData;
|
||||
private float x = 0;
|
||||
private float y = 0;
|
||||
private float z = 0;
|
||||
private float speed = 0;
|
||||
private int amount = 0;
|
||||
|
||||
/**
|
||||
* NORMAL:
|
||||
* frame-0.1-0.1-0.1-0-10
|
||||
* ITEM_CRACK:
|
||||
* iconcrack(Stone:0)-0.1-0.1-0.1-0-10
|
||||
*/
|
||||
public ParticleData(String str) {
|
||||
if (!Strings.isEmpty(str)) {
|
||||
try {
|
||||
String[] split = str.split("-");
|
||||
Matcher matcher = ITEM_PATTERN.matcher(split[0]);
|
||||
if (matcher.find()) {
|
||||
particle = EffLib.fromName(matcher.group(1));
|
||||
particleType = ParticleType.ITEM;
|
||||
particleData = particle.getName().startsWith("block") ? new EffLib.BlockData(ItemUtils.asMaterial(matcher.group(2).toUpperCase()), NumberConversions.toByte(matcher.group(3))) : new EffLib.ItemData(ItemUtils.asMaterial(matcher.group(2).toUpperCase()), NumberConversions.toByte(matcher.group(3)));
|
||||
} else {
|
||||
particle = EffLib.fromName(split[0]);
|
||||
}
|
||||
x = NumberConversions.toFloat(split[1]);
|
||||
y = NumberConversions.toFloat(split[2]);
|
||||
z = NumberConversions.toFloat(split[3]);
|
||||
speed = NumberConversions.toFloat(split[4]);
|
||||
amount = NumberConversions.toInt(split[5]);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void play(Location location) {
|
||||
try {
|
||||
switch (particleType) {
|
||||
case NORMAL:
|
||||
particle.display(x, y, z, speed, amount, location, 50);
|
||||
break;
|
||||
case ITEM:
|
||||
particle.display(particleData, x, y, z, speed, amount, location, 50);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package me.skymc.taboolib.particle.pack;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author 坏黑
|
||||
* @Since 2019-01-11 17:35
|
||||
*/
|
||||
public class ParticlePack {
|
||||
|
||||
private List<ParticleData> particles = Lists.newArrayList();
|
||||
|
||||
public ParticlePack(String str) {
|
||||
Arrays.stream(str.split(";")).forEach(this::add);
|
||||
}
|
||||
|
||||
public void add(String str) {
|
||||
particles.add(new ParticleData(str));
|
||||
}
|
||||
|
||||
public void play(Location location) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TabooLib.instance(), () -> particles.forEach(p -> p.play(location)));
|
||||
}
|
||||
|
||||
// *********************************
|
||||
//
|
||||
// Getter and Setter
|
||||
//
|
||||
// *********************************
|
||||
|
||||
public List<ParticleData> getParticles() {
|
||||
return particles;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package me.skymc.taboolib.particle.pack;
|
||||
|
||||
/**
|
||||
* @Author 坏黑
|
||||
* @Since 2019-01-11 17:45
|
||||
*/
|
||||
public enum ParticleType {
|
||||
|
||||
NORMAL, ITEM
|
||||
|
||||
}
|
@ -38,9 +38,6 @@ SERVER: false
|
||||
# 网络连接测试地址
|
||||
TEST-URL: 'aliyun.com'
|
||||
|
||||
# 下载依赖时启用的线程数
|
||||
DOWNLOAD-POOL-SIZE: 4
|
||||
|
||||
# 玩家列表(TAB-API)是否根据前缀排序
|
||||
TABLIST-SORT: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user