挖了个天坑。

This commit is contained in:
坏黑 2018-08-09 11:58:31 +08:00
parent 88cc9cc7bf
commit 600ac49622
7 changed files with 49 additions and 36 deletions

View File

@ -126,6 +126,13 @@
<scope>system</scope>
<systemPath>${basedir}/libs/1_8_R3.jar</systemPath>
</dependency>
<dependency>
<groupId>bungeecord</groupId>
<artifactId>bungeecord</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/BungeeCord.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun.tools</groupId>
<artifactId>jshell</artifactId>

View File

@ -19,9 +19,7 @@ import java.util.function.Consumer;
*/
public class TConfigWatcher {
private final ScheduledExecutorService service = Executors.newScheduledThreadPool(1,
new BasicThreadFactory.Builder().namingPattern("TConfigWatcherService-%d").build());
private final ScheduledExecutorService service = Executors.newScheduledThreadPool(1, new BasicThreadFactory.Builder().namingPattern("TConfigWatcherService-%d").build());
private final Map<WatchService, Triple<File, Object, Consumer<Object>>> map = new HashMap<>();
public TConfigWatcher() {
@ -42,6 +40,10 @@ public class TConfigWatcher {
}, 1000, 100, TimeUnit.MILLISECONDS);
}
public void addSimpleListener(File file, Runnable runnable) {
addListener(file, null, obj -> runnable.run());
}
public void addOnListen(File file, Object obj, Consumer<Object> consumer) {
try {
WatchService service = FileSystems.getDefault().newWatchService();
@ -82,5 +84,4 @@ public class TConfigWatcher {
}
});
}
}

View File

@ -148,7 +148,7 @@ public class Main extends JavaPlugin implements Listener {
// 启动脚本
JavaShell.javaShellSetup();
// 注册脚本
SkriptHandler.getInst();
SkriptHandler.register();
// 注册头衔
TagDataHandler.init(this);
// 载入语言文件
@ -167,7 +167,7 @@ public class Main extends JavaPlugin implements Listener {
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> PlayerDataManager.saveAllCaches(true, false), 20, 20 * 60);
// 文件监控
TLib.getTLib().getConfigWatcher().addListener(new File(getDataFolder(), "config.yml"), null, obj -> {
TLib.getTLib().getConfigWatcher().addSimpleListener(new File(getDataFolder(), "config.yml"), () -> {
reloadConfig();
TLocale.Logger.info("CONFIG.RELOAD-SUCCESS", inst.getName(), "config.yml");
});

View File

@ -0,0 +1,15 @@
package me.skymc.taboolib.bungee;
import net.md_5.bungee.api.plugin.Plugin;
/**
* @Author sky
* @Since 2018-08-09 11:47
*/
public class TabooLibBungee extends Plugin {
@Override
public void onEnable() {
super.onEnable();
}
}

View File

@ -13,23 +13,13 @@ import org.bukkit.inventory.ItemStack;
*/
public class SkriptHandler {
private static SkriptHandler inst = null;
private SkriptHandler() {
public static void register() {
if (Bukkit.getPluginManager().getPlugin("Skript") != null) {
try {
Skript.registerExpression(ExpressionItemCache.class, ItemStack.class, ExpressionType.SIMPLE, "taboolib itemcache %string%");
Skript.registerExpression(ExpressionTabooCodeItem.class, ItemStack.class, ExpressionType.SIMPLE, "taboocode itemcache %string%");
} catch (Exception ignored) {
}
}
public static SkriptHandler getInst() {
if (inst == null) {
synchronized (SkriptHandler.class) {
if (inst == null) {
inst = new SkriptHandler();
}
}
}
return inst;
}
}

View File

@ -0,0 +1,5 @@
name: TabooLib
main: me.skymc.taboolib.bungee.TabooLibBungee
version: ${project.version}
author: [lzzelAliz, 坏黑]

View File

@ -1,13 +1,11 @@
name: TabooLib
authors: [坏黑]
website: http://www.15imc.com/index.html
main: me.skymc.taboolib.Main
version: ${project.version}
author: [lzzelAliz, 坏黑]
depend: [Vault]
softdepend: [PlaceholderAPI, Skript, MassiveLag]
commands:
taboolib:
aliases: [tlib]
@ -29,6 +27,3 @@ commands:
translateuuid:
aliases: 'tuuid'
permission: taboolib.admin
depend: [Vault]
softdepend: [PlaceholderAPI, Skript, MassiveLag]