版本更新至 4.13
+ TellrawJoin 新增 append 方法用于拼接其他 json 信息 o 修复 1.12 版本载入报错的问题 o 修复 json 信息发送方式错误的问题
This commit is contained in:
parent
a8c6aafbce
commit
655e3c2619
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.skymc</groupId>
|
<groupId>me.skymc</groupId>
|
||||||
<artifactId>TabooLib</artifactId>
|
<artifactId>TabooLib</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -140,6 +140,8 @@ public class TLocale {
|
|||||||
|
|
||||||
public static class Tellraw extends TLocale {
|
public static class Tellraw extends TLocale {
|
||||||
|
|
||||||
|
private static final Class<?> chatSerializer = NMSUtils.getNMSClassSilent("ChatSerializer", "IChatBaseComponent");
|
||||||
|
private static final Method chatSerializerA = NMSUtils.getMethodSilent(chatSerializer, "a", String.class);
|
||||||
private static final Field playerConnection = NMSUtils.getFieldSilent(NMSUtil19.class_EntityPlayer, "playerConnection");
|
private static final Field playerConnection = NMSUtils.getFieldSilent(NMSUtil19.class_EntityPlayer, "playerConnection");
|
||||||
private static final Method sendPacket = NMSUtils.getMethodSilent(NMSUtil19.class_PlayerConnection, "sendPacket", NMSUtil19.class_Packet);
|
private static final Method sendPacket = NMSUtils.getMethodSilent(NMSUtil19.class_PlayerConnection, "sendPacket", NMSUtil19.class_Packet);
|
||||||
private static final Constructor<?> PacketPlayOutChat = NMSUtils.getConstructorSilent(NMSUtil19.class_PacketPlayOutChat, NMSUtil19.class_IChatBaseComponent);
|
private static final Constructor<?> PacketPlayOutChat = NMSUtils.getConstructorSilent(NMSUtil19.class_PacketPlayOutChat, NMSUtil19.class_IChatBaseComponent);
|
||||||
@ -147,7 +149,7 @@ public class TLocale {
|
|||||||
public static void send(CommandSender sender, String rawMessage) {
|
public static void send(CommandSender sender, String rawMessage) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
try {
|
try {
|
||||||
sendPacket.invoke(playerConnection.get(NMSUtils.getHandle(sender)), PacketPlayOutChat.newInstance(rawMessage));
|
sendPacket.invoke(playerConnection.get(NMSUtils.getHandle(sender)), PacketPlayOutChat.newInstance(chatSerializerA.invoke(null, rawMessage)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + rawMessage);
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + rawMessage);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ public class Main extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 提示信息
|
// 提示信息
|
||||||
TLocale.Logger.error("NOTIFY.SUCCESS-DISABLE");
|
TLocale.Logger.info("NOTIFY.SUCCESS-DISABLE");
|
||||||
|
|
||||||
// 结束连接
|
// 结束连接
|
||||||
if (connection != null && connection.isConnection()) {
|
if (connection != null && connection.isConnection()) {
|
||||||
|
@ -13,6 +13,7 @@ import me.skymc.taboolib.string.VariableFormatter;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -55,6 +56,14 @@ public class TellrawJson {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TellrawJson append(TellrawJson json) {
|
||||||
|
BaseComponent[] newArray = new BaseComponent[components.length + json.components.length];
|
||||||
|
System.arraycopy(components, 0, newArray, 0, components.length);
|
||||||
|
System.arraycopy(json.components, 0, newArray, components.length, json.components.length);
|
||||||
|
components = newArray;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public TellrawJson hoverText(String text) {
|
public TellrawJson hoverText(String text) {
|
||||||
getLatestComponent().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(text).create()));
|
getLatestComponent().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(text).create()));
|
||||||
return this;
|
return this;
|
||||||
|
@ -539,7 +539,7 @@ public class NMSUtil19 {
|
|||||||
class_NBTTagList_getDoubleMethod = class_NBTTagList.getMethod("e", Integer.TYPE);
|
class_NBTTagList_getDoubleMethod = class_NBTTagList.getMethod("e", Integer.TYPE);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering NBTTagList.getDouble, loading entities from schematics will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering NBTTagList.getDouble, loading entities from schematics will not work");
|
||||||
class_NBTTagList_getDoubleMethod = null;
|
class_NBTTagList_getDoubleMethod = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ public class NMSUtil19 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering entity movement accessors, vehicle control will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering entity movement accessors, vehicle control will not work");
|
||||||
class_Entity_jumpingField = null;
|
class_Entity_jumpingField = null;
|
||||||
class_Entity_moveStrafingField = null;
|
class_Entity_moveStrafingField = null;
|
||||||
class_Entity_moveForwardField = null;
|
class_Entity_moveForwardField = null;
|
||||||
@ -589,7 +589,7 @@ public class NMSUtil19 {
|
|||||||
Class<?> craftMagicNumbers = fixBukkitClass("org.bukkit.craftbukkit.util.CraftMagicNumbers");
|
Class<?> craftMagicNumbers = fixBukkitClass("org.bukkit.craftbukkit.util.CraftMagicNumbers");
|
||||||
class_CraftMagicNumbers_getBlockMethod = craftMagicNumbers.getMethod("getBlock", Material.class);
|
class_CraftMagicNumbers_getBlockMethod = craftMagicNumbers.getMethod("getBlock", Material.class);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering block durability accessor, durability-based block checks will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering block durability accessor, durability-based block checks will not work");
|
||||||
class_Block_durabilityField = null;
|
class_Block_durabilityField = null;
|
||||||
class_CraftMagicNumbers_getBlockMethod = null;
|
class_CraftMagicNumbers_getBlockMethod = null;
|
||||||
}
|
}
|
||||||
@ -614,7 +614,7 @@ public class NMSUtil19 {
|
|||||||
class_PacketPlayOutChat_constructor = class_PacketPlayOutChat.getConstructor(class_IChatBaseComponent, Byte.TYPE);
|
class_PacketPlayOutChat_constructor = class_PacketPlayOutChat.getConstructor(class_IChatBaseComponent, Byte.TYPE);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering action bar methods, action bar messages will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering action bar methods, action bar messages will not work");
|
||||||
class_PacketPlayOutChat = null;
|
class_PacketPlayOutChat = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ public class NMSUtil19 {
|
|||||||
class_CraftWorld_spawnMethod = class_CraftWorld.getMethod("spawn", Location.class, Class.class, CreatureSpawnEvent.SpawnReason.class);
|
class_CraftWorld_spawnMethod = class_CraftWorld.getMethod("spawn", Location.class, Class.class, CreatureSpawnEvent.SpawnReason.class);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering custom spawn method, spawn reasons will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred while registering custom spawn method, spawn reasons will not work");
|
||||||
class_CraftWorld_spawnMethod = null;
|
class_CraftWorld_spawnMethod = null;
|
||||||
class_Consumer = null;
|
class_Consumer = null;
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ public class NMSUtil19 {
|
|||||||
class_TileEntity_updateMethod = class_TileEntity.getMethod("update");
|
class_TileEntity_updateMethod = class_TileEntity.getMethod("update");
|
||||||
class_TileEntity_saveMethod = class_TileEntity.getMethod("save", class_NBTTagCompound);
|
class_TileEntity_saveMethod = class_TileEntity.getMethod("save", class_NBTTagCompound);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, handling of tile entities may not work well", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, handling of tile entities may not work well");
|
||||||
class_TileEntity_loadMethod = null;
|
class_TileEntity_loadMethod = null;
|
||||||
class_TileEntity_updateMethod = null;
|
class_TileEntity_updateMethod = null;
|
||||||
class_TileEntity_saveMethod = null;
|
class_TileEntity_saveMethod = null;
|
||||||
@ -651,7 +651,7 @@ public class NMSUtil19 {
|
|||||||
try {
|
try {
|
||||||
class_NBTCompressedStreamTools_loadFileMethod = class_NBTCompressedStreamTools.getMethod("a", InputStream.class);
|
class_NBTCompressedStreamTools_loadFileMethod = class_NBTCompressedStreamTools.getMethod("a", InputStream.class);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, schematics will not load", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, schematics will not load");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -659,7 +659,7 @@ public class NMSUtil19 {
|
|||||||
class_DamageSource_getMagicSourceMethod = class_DamageSource.getMethod("b", class_Entity, class_Entity);
|
class_DamageSource_getMagicSourceMethod = class_DamageSource.getMethod("b", class_Entity, class_Entity);
|
||||||
class_DamageSource_MagicField = class_DamageSource.getField("MAGIC");
|
class_DamageSource_MagicField = class_DamageSource.getField("MAGIC");
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, magic damage will not work, using normal damage instead", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, magic damage will not work, using normal damage instead");
|
||||||
class_EntityLiving_damageEntityMethod = null;
|
class_EntityLiving_damageEntityMethod = null;
|
||||||
class_DamageSource_getMagicSourceMethod = null;
|
class_DamageSource_getMagicSourceMethod = null;
|
||||||
class_DamageSource_MagicField = null;
|
class_DamageSource_MagicField = null;
|
||||||
@ -699,7 +699,7 @@ public class NMSUtil19 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, armor stand slots cannot be locked", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, armor stand slots cannot be locked");
|
||||||
class_EntityArmorStand_disabledSlotsField = null;
|
class_EntityArmorStand_disabledSlotsField = null;
|
||||||
}
|
}
|
||||||
if (class_EntityArmorStand_disabledSlotsField != null) {
|
if (class_EntityArmorStand_disabledSlotsField != null) {
|
||||||
@ -730,7 +730,7 @@ public class NMSUtil19 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, chest locking and unlocking will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, chest locking and unlocking will not work");
|
||||||
class_TileEntityContainer_setLock = null;
|
class_TileEntityContainer_setLock = null;
|
||||||
class_TileEntityContainer_getLock = null;
|
class_TileEntityContainer_getLock = null;
|
||||||
}
|
}
|
||||||
@ -750,7 +750,7 @@ public class NMSUtil19 {
|
|||||||
class_PlayerConnection_floatCountField.setAccessible(true);
|
class_PlayerConnection_floatCountField.setAccessible(true);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, player flight exemption will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, player flight exemption will not work");
|
||||||
class_PlayerConnection_floatCountField = null;
|
class_PlayerConnection_floatCountField = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,7 +769,7 @@ public class NMSUtil19 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, setting arrow lifespan will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, setting arrow lifespan will not work");
|
||||||
class_EntityArrow_lifeField = null;
|
class_EntityArrow_lifeField = null;
|
||||||
}
|
}
|
||||||
if (class_EntityArrow_lifeField != null) {
|
if (class_EntityArrow_lifeField != null) {
|
||||||
@ -780,7 +780,7 @@ public class NMSUtil19 {
|
|||||||
// 1.9 and up
|
// 1.9 and up
|
||||||
class_EntityDamageSource_setThornsMethod = class_EntityDamageSource.getMethod("w");
|
class_EntityDamageSource_setThornsMethod = class_EntityDamageSource.getMethod("w");
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, thorn damage override to hurt ender dragon will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, thorn damage override to hurt ender dragon will not work");
|
||||||
class_EntityDamageSource_setThornsMethod = null;
|
class_EntityDamageSource_setThornsMethod = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,7 +801,7 @@ public class NMSUtil19 {
|
|||||||
class_Entity_saveMethod = class_Entity.getMethod("e", class_NBTTagCompound);
|
class_Entity_saveMethod = class_Entity.getMethod("e", class_NBTTagCompound);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, saving entities to spawn eggs will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, saving entities to spawn eggs will not work");
|
||||||
class_Entity_getTypeMethod = null;
|
class_Entity_getTypeMethod = null;
|
||||||
class_Entity_saveMethod = null;
|
class_Entity_saveMethod = null;
|
||||||
}
|
}
|
||||||
@ -819,7 +819,7 @@ public class NMSUtil19 {
|
|||||||
class_ItemStack_createStackMethod = class_ItemStack.getMethod("createStack", class_NBTTagCompound);
|
class_ItemStack_createStackMethod = class_ItemStack.getMethod("createStack", class_NBTTagCompound);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, restoring inventories from schematics will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, restoring inventories from schematics will not work");
|
||||||
class_ItemStack_createStackMethod = null;
|
class_ItemStack_createStackMethod = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ public class NMSUtil19 {
|
|||||||
class_EntityArrow_damageField = class_EntityArrow.getDeclaredField("damage");
|
class_EntityArrow_damageField = class_EntityArrow.getDeclaredField("damage");
|
||||||
class_EntityArrow_damageField.setAccessible(true);
|
class_EntityArrow_damageField.setAccessible(true);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, setting arrow damage will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, setting arrow damage will not work");
|
||||||
class_EntityArrow_damageField = null;
|
class_EntityArrow_damageField = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ public class NMSUtil19 {
|
|||||||
class_Entity_isSilentMethod = class_Entity.getDeclaredMethod("ad");
|
class_Entity_isSilentMethod = class_Entity.getDeclaredMethod("ad");
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, silent entities will not work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, silent entities will not work");
|
||||||
class_Entity_setSilentMethod = null;
|
class_Entity_setSilentMethod = null;
|
||||||
class_Entity_isSilentMethod = null;
|
class_Entity_isSilentMethod = null;
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ public class NMSUtil19 {
|
|||||||
class_ArmorStand_setGravity = class_EntityArmorStand.getDeclaredMethod("setGravity", Boolean.TYPE);
|
class_ArmorStand_setGravity = class_EntityArmorStand.getDeclaredMethod("setGravity", Boolean.TYPE);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "An error occurred, hacky no-gravity armor stands won't work", ex);
|
Bukkit.getLogger().log(Level.WARNING, "An error occurred, hacky no-gravity armor stands won't work");
|
||||||
class_Entity_setNoGravity = null;
|
class_Entity_setNoGravity = null;
|
||||||
class_ArmorStand_setGravity = null;
|
class_ArmorStand_setGravity = null;
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ public class NMSUtil19 {
|
|||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
failed = true;
|
failed = true;
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "An unexpected error occurred initializing Magic", ex);
|
Bukkit.getLogger().log(Level.SEVERE, "An unexpected error occurred initializing Magic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user