mirror of
https://github.com/CarmJos/UserPrefix.git
synced 2024-09-19 20:15:47 +00:00
添加ASCII文字与插件介绍
This commit is contained in:
parent
cf749bf5c0
commit
f23fa03f7a
12
README.md
12
README.md
@ -301,7 +301,7 @@ itemNoPermission:
|
||||
|
||||
感谢您成为开源项目的支持者!
|
||||
|
||||
<img height=25% width=25% src="https://raw.githubusercontent.com/CarmJos/CarmJos/main/img/donate-code.jpg" />
|
||||
<img height=25% width=25% src="https://raw.githubusercontent.com/CarmJos/CarmJos/main/img/donate-code.jpg" alt=""/>
|
||||
|
||||
## 开源协议
|
||||
|
||||
@ -321,3 +321,13 @@ itemNoPermission:
|
||||
> 需要注意的是,分发的时候,需要明确提供源代码和二进制文件,另外,用于某些程序的某些协议有一些问题和限制,你可以看一下 @PierreJoye 写的 Practical Guide to GPL Compliance 一文。使用 GPL 协议,你必须在源代码代码中包含相应信息,以及协议本身。
|
||||
>
|
||||
> *以上文字来自 [五种开源协议GPL,LGPL,BSD,MIT,Apache](https://www.oschina.net/question/54100_9455) 。*
|
||||
|
||||
```text
|
||||
_ _ _____ __ _
|
||||
| | | | | __ \ / _|(_)
|
||||
| | | | ___ ___ _ __ | |__) |_ __ ___ | |_ _ __ __
|
||||
| | | |/ __| / _ \| '__|| ___/| '__|/ _ \| _|| |\ \/ /
|
||||
| |__| |\__ \| __/| | | | | | | __/| | | | > <
|
||||
\____/ |___/ \___||_| |_| |_| \___||_| |_|/_/\_\
|
||||
|
||||
```
|
@ -15,92 +15,124 @@ import cc.carm.plugin.userprefix.util.ColorParser;
|
||||
import cc.carm.plugin.userprefix.util.MessageUtil;
|
||||
import net.luckperms.api.event.user.UserDataRecalculateEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
private static Main instance;
|
||||
private static Main instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
showPluginName();
|
||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
log("加载配置文件...");
|
||||
ConfigManager.initConfig();
|
||||
PrefixManager.init();
|
||||
|
||||
log("加载配置文件...");
|
||||
ConfigManager.initConfig();
|
||||
PrefixManager.init();
|
||||
log("注册指令...");
|
||||
registerCommand("UserPrefix", new UserPrefixCommand());
|
||||
registerCommand("UserPrefixAdmin", new UserPrefixAdminCommand());
|
||||
|
||||
log("注册指令...");
|
||||
Bukkit.getPluginCommand("UserPrefix").setExecutor(new UserPrefixCommand());
|
||||
Bukkit.getPluginCommand("UserPrefixAdmin").setExecutor(new UserPrefixAdminCommand());
|
||||
log("注册监听器...");
|
||||
regListener(new UserListener());
|
||||
regListener(new ChatListener());
|
||||
ServiceManager.getService().getEventBus().subscribe(this, UserDataRecalculateEvent.class, UserNodeUpdateProcessor::process);
|
||||
|
||||
log("注册监听器...");
|
||||
regListener(new UserListener());
|
||||
regListener(new ChatListener());
|
||||
ServiceManager.getService().getEventBus().subscribe(this, UserDataRecalculateEvent.class, UserNodeUpdateProcessor::process);
|
||||
|
||||
if (MessageUtil.hasPlaceholderAPI()) {
|
||||
log("注册变量...");
|
||||
new UserPrefixExpansion(getInstance()).register();
|
||||
} else {
|
||||
log("未安装 PlaceholderAPI 不进行变量注册...");
|
||||
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI!");
|
||||
}
|
||||
if (MessageUtil.hasPlaceholderAPI()) {
|
||||
log("注册变量...");
|
||||
new UserPrefixExpansion(getInstance()).register();
|
||||
} else {
|
||||
log("未安装 PlaceholderAPI 不进行变量注册...");
|
||||
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI!");
|
||||
}
|
||||
|
||||
|
||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
|
||||
showAD();
|
||||
showAD();
|
||||
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
|
||||
}
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
@Override
|
||||
public void onDisable() {
|
||||
showPluginName();
|
||||
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
log("卸载监听器...");
|
||||
Bukkit.getServicesManager().unregisterAll(this);
|
||||
log("卸载监听器...");
|
||||
Bukkit.getServicesManager().unregisterAll(this);
|
||||
|
||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
|
||||
showAD();
|
||||
showAD();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册监听器
|
||||
*
|
||||
* @param listener 监听器
|
||||
*/
|
||||
public static void regListener(Listener listener) {
|
||||
Bukkit.getPluginManager().registerEvents(listener, getInstance());
|
||||
}
|
||||
/**
|
||||
* 注册监听器
|
||||
*
|
||||
* @param listener 监听器
|
||||
*/
|
||||
public static void regListener(Listener listener) {
|
||||
Bukkit.getPluginManager().registerEvents(listener, getInstance());
|
||||
}
|
||||
|
||||
public static void log(String message) {
|
||||
Bukkit.getConsoleSender().sendMessage(ColorParser.parse("[" + getInstance().getName() + "] " + message));
|
||||
}
|
||||
public static void log(String message) {
|
||||
Bukkit.getConsoleSender().sendMessage(ColorParser.parse("[" + getInstance().getName() + "] " + message));
|
||||
}
|
||||
|
||||
public static void debug(String message) {
|
||||
if (PrefixConfig.DEBUG.get()) {
|
||||
log("[DEBUG] " + message);
|
||||
}
|
||||
}
|
||||
public static void debug(String message) {
|
||||
if (PrefixConfig.DEBUG.get()) {
|
||||
log("[DEBUG] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
public static JavaPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public static JavaPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void showAD() {
|
||||
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
|
||||
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
|
||||
}
|
||||
|
||||
public static void registerCommand(String commandName,
|
||||
@NotNull CommandExecutor executor) {
|
||||
registerCommand(commandName, executor, null);
|
||||
}
|
||||
|
||||
public static void registerCommand(String commandName,
|
||||
@NotNull CommandExecutor executor,
|
||||
@Nullable TabCompleter tabCompleter) {
|
||||
PluginCommand command = Bukkit.getPluginCommand(commandName);
|
||||
if (command == null) return;
|
||||
command.setExecutor(executor);
|
||||
if (tabCompleter != null) command.setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
private void showPluginName() {
|
||||
log("&b _ _ &f _____ __ _ ");
|
||||
log("&b| | | | &f| __ \\ / _|(_) ");
|
||||
log("&b| | | | ___ ___ _ __ &f| |__) |_ __ ___ | |_ _ __ __");
|
||||
log("&b| | | |/ __| / _ \\| '__|&f| ___/| '__|/ _ \\| _|| |\\ \\/ /");
|
||||
log("&b| |__| |\\__ \\| __/| | &f| | | | | __/| | | | > < ");
|
||||
log("&b \\____/ |___/ \\___||_| &f|_| |_| \\___||_| |_|/_/\\_\\");
|
||||
log("&8 ");
|
||||
log("&8> &f" + getDescription().getWebsite());
|
||||
}
|
||||
|
||||
private void showAD() {
|
||||
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
|
||||
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user