版本更新至 3.65
新增:版本更新检测 新增:Language2Value 对象新增 broadcast() 方法来发送给所有玩家 新增:/language2 send 命令现在可以使用 ALL 代替所有玩家 删除:FileUtils 工具的三个文本读取方法的异常打印
This commit is contained in:
parent
06f6340863
commit
1d0219ed50
@ -38,6 +38,7 @@ import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.inventory.speciaitem.SpecialItem;
|
||||
import me.skymc.taboolib.javashell.JavaShell;
|
||||
import me.skymc.taboolib.listener.ListenerNetWork;
|
||||
import me.skymc.taboolib.listener.ListenerPlayerCommand;
|
||||
import me.skymc.taboolib.listener.ListenerPlayerQuit;
|
||||
import me.skymc.taboolib.listener.ListenerPlayerJump;
|
||||
@ -51,6 +52,7 @@ import me.skymc.taboolib.string.language2.Language2;
|
||||
import me.skymc.taboolib.support.SupportPlaceholder;
|
||||
import me.skymc.taboolib.team.TagUtils;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleManager;
|
||||
import me.skymc.taboolib.update.UpdateTask;
|
||||
import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.command.TLMCommands;
|
||||
import me.skymc.tlm.module.TabooLibraryModule;
|
||||
@ -223,6 +225,9 @@ public class Main extends JavaPlugin implements Listener {
|
||||
}
|
||||
}.runTask(this);
|
||||
|
||||
// 更新检测
|
||||
new UpdateTask();
|
||||
|
||||
// 启动
|
||||
started = true;
|
||||
}
|
||||
@ -316,6 +321,11 @@ public class Main extends JavaPlugin implements Listener {
|
||||
getServer().getPluginManager().registerEvents(new EntityUtils(), this);
|
||||
getServer().getPluginManager().registerEvents(new SignUtils(), this);
|
||||
}
|
||||
|
||||
// 如果 YUM 插件存在
|
||||
if (Bukkit.getPluginManager().getPlugin("YUM") != null) {
|
||||
getServer().getPluginManager().registerEvents(new ListenerNetWork(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum StorageType {
|
||||
|
@ -11,6 +11,20 @@ import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class TabooLib {
|
||||
|
||||
/**
|
||||
* 获取插件版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static double getPluginVersion() {
|
||||
try {
|
||||
return Double.valueOf(Main.getInst().getDescription().getVersion());
|
||||
}
|
||||
catch (Exception e) {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 NMS 版本
|
||||
*
|
||||
|
@ -23,7 +23,7 @@ public class Language2Command implements CommandExecutor {
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lLanguage2 Commands §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f /language2 send §8[§7玩家§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示");
|
||||
sender.sendMessage("§f /language2 send §8[§7玩家/ALL§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示");
|
||||
sender.sendMessage("§f /language2 reload §6- §e重载语言库");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
@ -37,19 +37,12 @@ public class Language2Command implements CommandExecutor {
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "§4参数错误");
|
||||
}
|
||||
else {
|
||||
// 获取玩家
|
||||
Player player = Bukkit.getPlayerExact(args[1]);
|
||||
if (player == null) {
|
||||
MsgUtils.send(sender, "§4玩家不在线");
|
||||
}
|
||||
else {
|
||||
// 时间
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
// 获取语言文件
|
||||
Language2Value value = Main.getExampleLangauge2().get(args[2]);
|
||||
|
||||
// 如果有变量参数
|
||||
if (args.length > 3) {
|
||||
int i = 0;
|
||||
@ -59,8 +52,22 @@ public class Language2Command implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是公告
|
||||
if (args[1].equals("ALL")) {
|
||||
// 发送信息
|
||||
value.broadcast();
|
||||
}
|
||||
else {
|
||||
// 获取玩家
|
||||
Player player = Bukkit.getPlayerExact(args[1]);
|
||||
if (player == null) {
|
||||
MsgUtils.send(sender, "§4玩家不在线");
|
||||
}
|
||||
else {
|
||||
// 发送信息
|
||||
value.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果发送者是玩家
|
||||
if (sender instanceof Player && ((Player) sender).getItemInHand().getType().equals(Material.COMMAND)) {
|
||||
@ -68,7 +75,6 @@ public class Language2Command implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import me.skymc.taboolib.client.LogClient;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.methods.MethodsUtils;
|
||||
|
||||
public class FileUtils {
|
||||
@ -78,7 +79,7 @@ public class FileUtils {
|
||||
bos.close();
|
||||
return new String(bos.toByteArray(), encode);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
MsgUtils.warn("输入流读取出错: &4" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -101,7 +102,7 @@ public class FileUtils {
|
||||
fin.close();
|
||||
return new String(bos.toByteArray(), encode);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
MsgUtils.warn("文件读取出错: &4" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -123,7 +124,7 @@ public class FileUtils {
|
||||
bin.close();
|
||||
return new String(bos.toByteArray(), conn.getContentEncoding() == null ? "UTF-8" : conn.getContentEncoding());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
MsgUtils.warn("网络访问出错: &4" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
28
src/main/src/me/skymc/taboolib/listener/ListenerNetWork.java
Normal file
28
src/main/src/me/skymc/taboolib/listener/ListenerNetWork.java
Normal file
@ -0,0 +1,28 @@
|
||||
package me.skymc.taboolib.listener;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import pw.yumc.Yum.events.PluginNetworkEvent;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月23日 下午11:10:03
|
||||
*/
|
||||
public class ListenerNetWork implements Listener {
|
||||
|
||||
public static final String GG = "本监听只是为了防止本插件的更新检测被 YUM 插件阻止,别无它用。";
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onNetWork(PluginNetworkEvent e) {
|
||||
if (e.getPlugin() != null && e.getPlugin().equals(Main.getInst())) {
|
||||
// 取消阻止
|
||||
e.setCancelled(false);
|
||||
// 后台提示
|
||||
MsgUtils.warn("已取消 &4YUM &c对本插件网络访问的阻止!");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.skymc.taboolib.string.language2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -199,6 +200,17 @@ public class Language2Value {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全服公告
|
||||
*/
|
||||
public void broadcast() {
|
||||
List<Player> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player);
|
||||
}
|
||||
send(players);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文本
|
||||
*
|
||||
|
56
src/main/src/me/skymc/taboolib/update/UpdateTask.java
Normal file
56
src/main/src/me/skymc/taboolib/update/UpdateTask.java
Normal file
@ -0,0 +1,56 @@
|
||||
package me.skymc.taboolib.update;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月23日 下午10:39:14
|
||||
*/
|
||||
public class UpdateTask {
|
||||
|
||||
/**
|
||||
* 检测更新
|
||||
*/
|
||||
public UpdateTask() {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 是否禁用
|
||||
if (!Main.getInst().getConfig().getBoolean("UPDATE-CHECK")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String value = FileUtils.getStringFromURL("https://github.com/Bkm016/TabooLib/releases", 1024);
|
||||
Pattern pattern = Pattern.compile("<a href=\"/Bkm016/TabooLib/releases/tag/(\\S+)\">");
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
if (matcher.find()) {
|
||||
// 最新版本
|
||||
double newVersion = Double.valueOf(matcher.group(1));
|
||||
// 如果是最新版
|
||||
if (TabooLib.getPluginVersion() == newVersion) {
|
||||
MsgUtils.send("插件已是最新版, 无需更新!");
|
||||
}
|
||||
else {
|
||||
MsgUtils.send("&8####################################################");
|
||||
MsgUtils.send("检测到有新的版本更新!");
|
||||
MsgUtils.send("当前版本: &f" + TabooLib.getPluginVersion());
|
||||
MsgUtils.send("最新版本: &f" + newVersion);
|
||||
MsgUtils.send("下载地址: &fhttp://www.mcbbs.net/thread-773065-1-1.html");
|
||||
MsgUtils.send("开源地址: &fhttps://github.com/Bkm016/TabooLib/");
|
||||
MsgUtils.send("&8####################################################");
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLaterAsynchronously(Main.getInst(), 100);
|
||||
}
|
||||
}
|
@ -17,6 +17,9 @@ DATAURL:
|
||||
# 启用后将收到来自其他插件的调试信息
|
||||
DEBUG: false
|
||||
|
||||
# 是否启用更新检测
|
||||
UPDATE-CHECK: true
|
||||
|
||||
# 是否在关闭服务器时清理玩家数据
|
||||
# 该配置将在启用数据库储存时失效
|
||||
DELETE-DATA: false
|
||||
|
Loading…
Reference in New Issue
Block a user