Skip to content

Commit

Permalink
版本更新至 3.59
Browse files Browse the repository at this point in the history
调整:帮助命令的 JSON 版本改为 1.9+ 版本显示
调整:插件尚未启动完成则不会执行 onDisable() 方法
修复:ActionUtils 工具在 1.12 版本下失效的问题,感谢 MCBBS 用户 Innovators 的测试。
  • Loading branch information
Bkm016 committed Feb 20, 2018
1 parent f2fd7a8 commit f5a797b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/main/src/me/skymc/taboolib/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class Main extends JavaPlugin implements Listener {
private static LogClient client;
@Getter
private static Language2 exampleLangauge2;
@Getter
private static boolean started;

public static Random getRandom() {
return NumberUtils.getRand();
Expand Down Expand Up @@ -220,12 +222,22 @@ public void run() {
TLM.getInst();
}
}.runTask(this);

// 启动
started = true;
}

@Override
public void onDisable() {
disable = true;

// 如果插件尚未启动完成
if (!started) {
MsgUtils.send("&c插件尚未启动完成, 已跳过卸载代码");
MsgUtils.send("&c插件作者: &4坏黑");
return;
}

// 保存数据
Bukkit.getOnlinePlayers().forEach(x -> DataUtils.saveOnline(x.getName()));
// 结束线程
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public HelpCommand(CommandSender sender, String[] args) {
helps.put("§e", null);
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("§b§l----- §3§lTaooLib Commands §b§l-----");
sender.sendMessage("§f");
Expand Down
14 changes: 12 additions & 2 deletions src/main/src/me/skymc/taboolib/display/ActionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.methods.MethodsUtils;
import net.minecraft.server.v1_12_R1.ChatMessageType;

public class ActionUtils {

Expand Down Expand Up @@ -44,8 +46,16 @@ public static void send(Player p, String msg)
try
{
Object ab = getNMSClass("ChatComponentText").getConstructor(new Class[] { String.class }).newInstance(new Object[] { msg });
Constructor<?> ac = getNMSClass("PacketPlayOutChat").getConstructor(new Class[] { getNMSClass("IChatBaseComponent"), Byte.TYPE });
Object abPacket = ac.newInstance(new Object[] { ab, Byte.valueOf((byte) 2) });
Constructor<?> ac = null;
Object abPacket = null;
// ����汾���� 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);
}
catch (Exception ex)
Expand Down

0 comments on commit f5a797b

Please sign in to comment.