版本更新至 3.59

调整:帮助命令的 JSON 版本改为 1.9+ 版本显示
调整:插件尚未启动完成则不会执行 onDisable() 方法
修复:ActionUtils 工具在 1.12 版本下失效的问题,感谢 MCBBS 用户 Innovators 的测试。
This commit is contained in:
坏黑 2018-02-20 15:03:37 +08:00
parent 09c063462f
commit e7ebf50ff2
3 changed files with 25 additions and 3 deletions

View File

@ -88,6 +88,8 @@ public class Main extends JavaPlugin implements Listener {
private static LogClient client; private static LogClient client;
@Getter @Getter
private static Language2 exampleLangauge2; private static Language2 exampleLangauge2;
@Getter
private static boolean started;
public static Random getRandom() { public static Random getRandom() {
return NumberUtils.getRand(); return NumberUtils.getRand();
@ -220,12 +222,22 @@ public class Main extends JavaPlugin implements Listener {
TLM.getInst(); TLM.getInst();
} }
}.runTask(this); }.runTask(this);
// 启动
started = true;
} }
@Override @Override
public void onDisable() { public void onDisable() {
disable = true; disable = true;
// 如果插件尚未启动完成
if (!started) {
MsgUtils.send("&c插件尚未启动完成, 已跳过卸载代码");
MsgUtils.send("&c插件作者: &4坏黑");
return;
}
// 保存数据 // 保存数据
Bukkit.getOnlinePlayers().forEach(x -> DataUtils.saveOnline(x.getName())); Bukkit.getOnlinePlayers().forEach(x -> DataUtils.saveOnline(x.getName()));
// 结束线程 // 结束线程

View File

@ -46,7 +46,7 @@ public class HelpCommand extends SubCommand {
helps.put("§e", null); helps.put("§e", null);
helps.put("/taboolib importdata", "§4向数据库导入本地数据 §8(该操作将会清空数据库)"); helps.put("/taboolib importdata", "§4向数据库导入本地数据 §8(该操作将会清空数据库)");
if (sender instanceof ConsoleCommandSender || TabooLib.getVerint() < 10800) { if (sender instanceof ConsoleCommandSender || TabooLib.getVerint() < 10900) {
sender.sendMessage("§f"); sender.sendMessage("§f");
sender.sendMessage("§b§l----- §3§lTaooLib Commands §b§l-----"); sender.sendMessage("§b§l----- §3§lTaooLib Commands §b§l-----");
sender.sendMessage("§f"); sender.sendMessage("§f");

View File

@ -4,7 +4,9 @@ import java.lang.reflect.Constructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.methods.MethodsUtils; import me.skymc.taboolib.methods.MethodsUtils;
import net.minecraft.server.v1_12_R1.ChatMessageType;
public class ActionUtils { public class ActionUtils {
@ -44,8 +46,16 @@ public class ActionUtils {
try try
{ {
Object ab = getNMSClass("ChatComponentText").getConstructor(new Class[] { String.class }).newInstance(new Object[] { msg }); Object ab = getNMSClass("ChatComponentText").getConstructor(new Class[] { String.class }).newInstance(new Object[] { msg });
Constructor<?> ac = getNMSClass("PacketPlayOutChat").getConstructor(new Class[] { getNMSClass("IChatBaseComponent"), Byte.TYPE }); Constructor<?> ac = null;
Object abPacket = ac.newInstance(new Object[] { ab, Byte.valueOf((byte) 2) }); Object abPacket = null;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1.11.0
if (TabooLib.getVerint() > 11100) {
Class<?> chatMessageType = getNMSClass("ChatMessageType");
ac = getNMSClass("PacketPlayOutChat").getConstructor(getNMSClass("IChatBaseComponent"), chatMessageType);
abPacket = ac.newInstance(ab, chatMessageType.getMethod("a", Byte.TYPE).invoke(null, (byte) 2));
} else {
abPacket = ac.newInstance(ab, Byte.valueOf((byte) 2));
}
sendPacket(p, abPacket); sendPacket(p, abPacket);
} }
catch (Exception ex) catch (Exception ex)