perf(bukkit): 优化代码
This commit is contained in:
@@ -154,6 +154,7 @@ public abstract class ParentCommand extends ChildCommand {
|
|||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return childCommands.stream()
|
return childCommands.stream()
|
||||||
|
.filter(o -> o.hasPermission(sender))
|
||||||
.map(ChildCommand::getName)
|
.map(ChildCommand::getName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -164,6 +165,7 @@ public abstract class ParentCommand extends ChildCommand {
|
|||||||
}
|
}
|
||||||
args[0] = args[0].toLowerCase();
|
args[0] = args[0].toLowerCase();
|
||||||
return childCommands.stream()
|
return childCommands.stream()
|
||||||
|
.filter(o -> o.hasPermission(sender))
|
||||||
.map(ChildCommand::getName)
|
.map(ChildCommand::getName)
|
||||||
.filter(o -> o.toLowerCase().startsWith(args[0]))
|
.filter(o -> o.toLowerCase().startsWith(args[0]))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package cn.hamster3.mc.plugin.core.bukkit.util;
|
package cn.hamster3.mc.plugin.core.bukkit.util;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.core.bukkit.HamsterCorePlugin;
|
|
||||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -213,11 +212,11 @@ public final class BukkitUtils {
|
|||||||
public static YamlConfiguration getPluginConfig(@NotNull Plugin plugin, @NotNull String filename) {
|
public static YamlConfiguration getPluginConfig(@NotNull Plugin plugin, @NotNull String filename) {
|
||||||
File dataFolder = plugin.getDataFolder();
|
File dataFolder = plugin.getDataFolder();
|
||||||
if (dataFolder.mkdirs()) {
|
if (dataFolder.mkdirs()) {
|
||||||
HamsterCorePlugin.getInstance().getLogger().info("已为插件 %s 生成存档文件夹...");
|
plugin.getLogger().info("已生成插件存档文件夹...");
|
||||||
}
|
}
|
||||||
File file = new File(dataFolder, filename);
|
File file = new File(dataFolder, filename);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
try (InputStream stream = plugin.getClass().getResourceAsStream(filename)) {
|
try (InputStream stream = plugin.getResource(filename)) {
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
throw new IllegalArgumentException("在插件 " + plugin.getName() + " 的文件内部未找到 " + filename + " !");
|
throw new IllegalArgumentException("在插件 " + plugin.getName() + " 的文件内部未找到 " + filename + " !");
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
datasource:
|
datasource:
|
||||||
# 数据库链接驱动地址
|
# 数据库链接驱动地址
|
||||||
# 除非你知道自己在做什么,否则不建议更改该项
|
# 除非你知道自己在做什么,否则不建议更改该项
|
||||||
|
# 旧版服务端(低于1.13)请使用:com.mysql.jdbc.Driver
|
||||||
driver: "com.mysql.cj.jdbc.Driver"
|
driver: "com.mysql.cj.jdbc.Driver"
|
||||||
# 数据库链接填写格式:
|
# 数据库链接填写格式:
|
||||||
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
||||||
|
Reference in New Issue
Block a user