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