mirror of
https://github.com/Verdurae/PlaceholderPlus.git
synced 2026-11-25 06:14:31 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4e53ea858 | ||
|
|
7e6f4eb53d |
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'org.verdurae'
|
||||
version = '1.1.3-SNAPSHOT'
|
||||
version = '1.1.4-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -31,6 +31,7 @@ public class PlaceholderPlusCommand implements CommandExecutor, TabCompleter {
|
||||
PluginUtil.serverData = new YamlConfiguration();
|
||||
PluginUtil.loadAllPlayerData();
|
||||
PluginUtil.loadServerData();
|
||||
PluginUtil.loadAllHolder();
|
||||
PlaceholderPlus.timer.cancel();
|
||||
PlaceholderPlus.newTimer();
|
||||
sender.sendMessage("已重载");
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class PlaceholderPlus extends JavaPlugin {
|
||||
public static Logger logger;
|
||||
public static FileConfiguration config;
|
||||
public static boolean jsSupport = false;
|
||||
public static ArrayList<PlaceholderExpansion> expansions = new ArrayList<>();
|
||||
public static ArrayList<PlaceholderExpansion> expansions;
|
||||
public static File dataFolder;
|
||||
public static File serverDataFolder;
|
||||
public static File playerDataFolder;
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.verdurae.placeholderplus.Util;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,7 +19,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PluginUtil {
|
||||
@@ -57,6 +58,7 @@ public class PluginUtil {
|
||||
}
|
||||
|
||||
public static void loadAllHolder() {
|
||||
PlaceholderPlus.expansions = new ArrayList<>();
|
||||
PlaceholderPlus.expansions.add(new ThisPlaceholder());
|
||||
File JsFolder = new File(PlaceholderPlus.dataFolder, "Js");
|
||||
JsFolder.mkdirs();
|
||||
@@ -65,11 +67,9 @@ public class PluginUtil {
|
||||
try {
|
||||
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
|
||||
ScriptEngine engine = factory.getScriptEngine();
|
||||
Map<String, Object> value = PlaceholderPlus.config.getValues(true);
|
||||
for (String key : value.keySet()) {
|
||||
if (key.startsWith("JsImportPacket.")) {
|
||||
engine.put(key.replace("JsImportPacket.", ""), Class.forName(key));
|
||||
}
|
||||
ConfigurationSection value = PlaceholderPlus.config.getConfigurationSection("JsImportPacket");
|
||||
for (String key : value.getKeys(false)) {
|
||||
engine.put(key, Class.forName(value.getString(key)));
|
||||
}
|
||||
InputStreamReader reader = new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);
|
||||
char[] buffer = new char[1024];
|
||||
@@ -111,13 +111,13 @@ public class PluginUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PlaceholderExpansion expansion : PlaceholderPlus.expansions) {
|
||||
for (PlaceholderExpansion expansion : new ArrayList<>(PlaceholderPlus.expansions)) {
|
||||
if (expansion.canRegister()) expansion.register();
|
||||
}
|
||||
}
|
||||
|
||||
public static void unloadAllHolder() {
|
||||
for (PlaceholderExpansion expansion : PlaceholderPlus.expansions) {
|
||||
for (PlaceholderExpansion expansion : new ArrayList<>(PlaceholderPlus.expansions)) {
|
||||
expansion.unregister();
|
||||
}
|
||||
}
|
||||
@@ -132,4 +132,4 @@ public class PluginUtil {
|
||||
new PlayerData(name, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ Setting:
|
||||
|
||||
# 要给js变量导的包,新手不建议使用
|
||||
JsImportPacket:
|
||||
"Bukkit": "org.bukkit.Bukkit"
|
||||
"Arrays": "java.util.Arrays"
|
||||
"PAPI": "me.clip.placeholderapi.PlaceholderAPI"
|
||||
Bukkit: "org.bukkit.Bukkit"
|
||||
Arrays: "java.util.Arrays"
|
||||
PAPI: "me.clip.placeholderapi.PlaceholderAPI"
|
||||
|
||||
# 自定义变量
|
||||
# 最终解析的变量是%pp_变量类型_变量名%
|
||||
|
||||
Reference in new issue
Block a user