挖了个天坑。

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> <scope>system</scope>
<systemPath>${basedir}/libs/1_8_R3.jar</systemPath> <systemPath>${basedir}/libs/1_8_R3.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>bungeecord</groupId>
<artifactId>bungeecord</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/BungeeCord.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>com.sun.tools</groupId> <groupId>com.sun.tools</groupId>
<artifactId>jshell</artifactId> <artifactId>jshell</artifactId>

View File

@ -19,9 +19,7 @@ import java.util.function.Consumer;
*/ */
public class TConfigWatcher { public class TConfigWatcher {
private final ScheduledExecutorService service = Executors.newScheduledThreadPool(1, private final ScheduledExecutorService service = Executors.newScheduledThreadPool(1, new BasicThreadFactory.Builder().namingPattern("TConfigWatcherService-%d").build());
new BasicThreadFactory.Builder().namingPattern("TConfigWatcherService-%d").build());
private final Map<WatchService, Triple<File, Object, Consumer<Object>>> map = new HashMap<>(); private final Map<WatchService, Triple<File, Object, Consumer<Object>>> map = new HashMap<>();
public TConfigWatcher() { public TConfigWatcher() {
@ -42,6 +40,10 @@ public class TConfigWatcher {
}, 1000, 100, TimeUnit.MILLISECONDS); }, 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) { public void addOnListen(File file, Object obj, Consumer<Object> consumer) {
try { try {
WatchService service = FileSystems.getDefault().newWatchService(); 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(); JavaShell.javaShellSetup();
// 注册脚本 // 注册脚本
SkriptHandler.getInst(); SkriptHandler.register();
// 注册头衔 // 注册头衔
TagDataHandler.init(this); 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); 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(); reloadConfig();
TLocale.Logger.info("CONFIG.RELOAD-SUCCESS", inst.getName(), "config.yml"); 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 { public class SkriptHandler {
private static SkriptHandler inst = null; public static void register() {
private SkriptHandler() {
if (Bukkit.getPluginManager().getPlugin("Skript") != null) { if (Bukkit.getPluginManager().getPlugin("Skript") != null) {
try {
Skript.registerExpression(ExpressionItemCache.class, ItemStack.class, ExpressionType.SIMPLE, "taboolib itemcache %string%"); Skript.registerExpression(ExpressionItemCache.class, ItemStack.class, ExpressionType.SIMPLE, "taboolib itemcache %string%");
Skript.registerExpression(ExpressionTabooCodeItem.class, ItemStack.class, ExpressionType.SIMPLE, "taboocode 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 name: TabooLib
authors: [坏黑]
website: http://www.15imc.com/index.html
main: me.skymc.taboolib.Main main: me.skymc.taboolib.Main
version: ${project.version} version: ${project.version}
author: [lzzelAliz, 坏黑]
depend: [Vault]
softdepend: [PlaceholderAPI, Skript, MassiveLag]
commands: commands:
taboolib: taboolib:
aliases: [tlib] aliases: [tlib]
@ -29,6 +27,3 @@ commands:
translateuuid: translateuuid:
aliases: 'tuuid' aliases: 'tuuid'
permission: taboolib.admin permission: taboolib.admin
depend: [Vault]
softdepend: [PlaceholderAPI, Skript, MassiveLag]