Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b8ce53553 | ||
|
|
6b157320c4 | ||
|
|
ba3da92061 | ||
|
|
dc6ce9c260 | ||
|
|
cf45b8e436 | ||
|
|
fc8966dab0 | ||
|
|
c537e72a27 | ||
|
|
dee359a37d | ||
|
|
34f67345e2 | ||
|
|
d937f5d89e | ||
|
|
856a5f182f | ||
|
|
6653b9c057 | ||
|
|
0b60780fe2 | ||
|
|
a16b2ea462 | ||
|
|
05771d975c | ||
|
|
417b63e86d | ||
|
|
01da231510 | ||
|
|
5e2559c1ee | ||
|
|
0bb784f7f2 | ||
|
|
eef3bf80c8 |
No files matched your search
@@ -5,8 +5,8 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>me.dadus33</groupId>
|
||||
<artifactId>chatitem</artifactId>
|
||||
<version>2.4.7</version>
|
||||
<artifactId>ChatItem</artifactId>
|
||||
<version>2.4.8</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -85,13 +85,13 @@
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<version>5.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>4.6.2</version>
|
||||
<version>4.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -118,10 +118,16 @@
|
||||
<version>2.2.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MajekDev</groupId>
|
||||
<artifactId>HexNicks</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.13.0</version>
|
||||
<version>4.14.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -142,6 +148,12 @@
|
||||
<version>8.57.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.Auxilor</groupId>
|
||||
<artifactId>EcoEnchants</artifactId>
|
||||
<version>10.23.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.kangarko</groupId>
|
||||
<artifactId>ChatControl-Free</artifactId>
|
||||
@@ -154,6 +166,12 @@
|
||||
<version>3.7.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.willfp</groupId>
|
||||
<artifactId>eco</artifactId>
|
||||
<version>6.65.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -25,6 +25,7 @@ import me.dadus33.chatitem.commands.CIReloadCommand;
|
||||
import me.dadus33.chatitem.commands.ChatItemCommand;
|
||||
import me.dadus33.chatitem.hook.ChatControlSupport;
|
||||
import me.dadus33.chatitem.hook.ChatManagerSupport;
|
||||
import me.dadus33.chatitem.hook.ecoenchants.EcoEnchantsSupport;
|
||||
import me.dadus33.chatitem.itemnamer.NamerManager;
|
||||
import me.dadus33.chatitem.listeners.InventoryListener;
|
||||
import me.dadus33.chatitem.listeners.JoinListener;
|
||||
@@ -37,7 +38,7 @@ import me.dadus33.chatitem.utils.Version;
|
||||
public class ChatItem extends JavaPlugin {
|
||||
|
||||
public final static int CFG_VER = 13;
|
||||
public static boolean discordSrvSupport = false, ecoEnchantsSupport = false, hasNewVersion = false;
|
||||
public static boolean discordSrvSupport = false, hasNewVersion = false;
|
||||
private static ChatItem instance;
|
||||
private final String brandChannelName = Version.getVersion().isNewerOrEquals(Version.V1_13) ? "minecraft:brand" : "MC|Brand";
|
||||
private final List<ChatManager> chatManager = new ArrayList<>();
|
||||
@@ -160,8 +161,7 @@ public class ChatItem extends JavaPlugin {
|
||||
ChatManagerSupport.init(this);
|
||||
plugins.add("ChatManager");
|
||||
}
|
||||
if (pm.isPluginEnabled("EcoEnchants") && pm.getPlugin("EcoEnchants").getDescription().getVersion().startsWith("8.")) {
|
||||
ecoEnchantsSupport = true;
|
||||
if (pm.isPluginEnabled("EcoEnchants") && EcoEnchantsSupport.load()) {
|
||||
plugins.add("EcoEnchants");
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Translation {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static String get(ItemStack item) {
|
||||
String key = (item.getType().isBlock() ? "block" : "item") + ".minecraft." + item.getType().name().toLowerCase().replace("_", ".");
|
||||
String key = (item.getType().isBlock() ? "block" : "item") + ".minecraft." + item.getType().name().toLowerCase();
|
||||
if (messages != null && messages.has(key)) {
|
||||
return messages.get(key).getAsString();
|
||||
} else
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.hook.EcoEnchantsSupport;
|
||||
import me.dadus33.chatitem.hook.ecoenchants.EcoEnchantsSupport;
|
||||
import me.dadus33.chatitem.itemnamer.NamerManager;
|
||||
import me.dadus33.chatitem.utils.ItemUtils;
|
||||
import me.dadus33.chatitem.utils.Utils;
|
||||
@@ -93,19 +93,8 @@ public abstract class ChatManager {
|
||||
public static ItemStack getUsableItem(Player p) {
|
||||
ItemStack item = HandItem.getBetterItem(p).clone();
|
||||
|
||||
if (ChatItem.ecoEnchantsSupport) {
|
||||
List<String> addLore = EcoEnchantsSupport.getLores(item);
|
||||
if (!addLore.isEmpty()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List<String> lores = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
for (int i = 0; i < addLore.size(); i++)
|
||||
lores.add(i, addLore.get(i));
|
||||
|
||||
meta.setLore(lores);
|
||||
item.setItemMeta(meta);
|
||||
ChatItem.debug("Added " + addLore.size() + " lores from EcoEnchants");
|
||||
} else
|
||||
ChatItem.debug("No lore to add from EcoEnchants");
|
||||
if (EcoEnchantsSupport.hasSupport()) {
|
||||
item = EcoEnchantsSupport.manageItem(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
+1
-2
@@ -65,10 +65,9 @@ public class AdventureComponentManager implements IComponentManager {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, Storage c) throws Exception {
|
||||
String itemName = ChatManager.getNameOfItem(chat.getPlayer(), item, c);
|
||||
String itemName = ChatManager.getNameOfItem(chat.getPlayer(), item, c);ChatItem.debug("NBT tag: " + PacketUtils.getNbtTag(item));;
|
||||
return manage(p, chat, packet, itemName, HoverEvent.showItem(Key.key(item.getType().getKey().getKey()), item.getAmount(), BinaryTagHolder.of(PacketUtils.getNbtTag(item))));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class ComponentNMSManager implements IComponentManager {
|
||||
|
||||
@Override
|
||||
public String getBaseComponentAsJSON(ChatItemPacket packet) {
|
||||
Object chatBaseComp = packet.getContent().getSpecificModifier(PacketUtils.COMPONENT_CLASS).readSafely(0);
|
||||
Object chatBaseComp = packet.getContent().getChatComponents().readSafely(0);
|
||||
if (chatBaseComp != null) {
|
||||
try {
|
||||
return PacketUtils.CHAT_SERIALIZER.getMethod("a", PacketUtils.COMPONENT_CLASS).invoke(null, chatBaseComp).toString();
|
||||
|
||||
@@ -26,7 +26,6 @@ import me.dadus33.chatitem.chatmanager.v1.PacketEditingChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.IComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.hook.AdventureComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.hook.ComponentNMSManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.hook.IChatBaseComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.hook.PCMComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.hook.StringComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.json.JSONManipulator;
|
||||
@@ -60,7 +59,7 @@ public class ChatPacketManager extends PacketHandler {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (IComponentManager getter : Arrays.asList(new StringComponentManager(), new IChatBaseComponentManager(), new ComponentNMSManager(), new PCMComponentManager())) {
|
||||
for (IComponentManager getter : Arrays.asList(new StringComponentManager(), new ComponentNMSManager(), new PCMComponentManager())) {
|
||||
tryRegister(getter);
|
||||
}
|
||||
try {
|
||||
@@ -91,10 +90,10 @@ public class ChatPacketManager extends PacketHandler {
|
||||
String json = "{}";
|
||||
IComponentManager choosedGetter = null;
|
||||
if (version.isNewerOrEquals(Version.V1_19)) {
|
||||
if (packet.getIntegers().readSafely(0, 0) > 1) { // not parsed chat message type
|
||||
/*if (packet.getIntegers().readSafely(0, 0) > 1) { // not parsed chat message type
|
||||
ChatItem.debug("Invalid int: " + packet.getIntegers().read(0));
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
choosedGetter = new StringComponentManager();
|
||||
json = choosedGetter.getBaseComponentAsJSON(e); // if null, will be re-checked so anyway
|
||||
} else if (version.isNewerOrEquals(Version.V1_12)) {
|
||||
@@ -111,7 +110,8 @@ public class ChatPacketManager extends PacketHandler {
|
||||
choosedGetter = getters;
|
||||
if (ChatManager.containsSeparator(json))
|
||||
break; // be sure it's valid one
|
||||
}
|
||||
} else
|
||||
ChatItem.debug("Null JSON for manager " + getters.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
if (json == null || choosedGetter == null) {
|
||||
|
||||
+3
-3
@@ -86,9 +86,9 @@ public class INC2Channel extends ChannelAbstract {
|
||||
|
||||
@Override
|
||||
public Channel getChannel(Player p) throws Exception {
|
||||
Class<?> networkClass = PacketUtils.getNmsClass("NetworkManager", "network.");
|
||||
Object networkManager = ReflectionUtils.getFirstWith(getPlayerConnection(p), PacketUtils.getNmsClass("PlayerConnection", "server.network."), networkClass);
|
||||
return ReflectionUtils.getFirstWith(networkManager, networkClass, Channel.class);
|
||||
Object playerConnection = getPlayerConnection(p);
|
||||
Object networkManager = ReflectionUtils.getFirstWith(playerConnection, playerConnection.getClass(), PacketUtils.getNmsClass("NetworkManager", "network."));
|
||||
return ReflectionUtils.getFirstWith(networkManager, networkManager.getClass(), Channel.class);
|
||||
}
|
||||
|
||||
private class ChannelHandlerSent extends ChannelOutboundHandlerAdapter {
|
||||
|
||||
@@ -168,12 +168,13 @@ public class ChatListener implements Listener {
|
||||
if (args == 'r' && colorCode.isEmpty()) {
|
||||
color = ChatColor.RESET;
|
||||
continue;
|
||||
} else if(args == 'x') {
|
||||
if(!colorCode.isEmpty()) {
|
||||
color = ColorManager.getColor(colorCode);
|
||||
colorCode = ""; // clean for previous things
|
||||
}
|
||||
}
|
||||
if (args == 'x' && !colorCode.isEmpty()) {
|
||||
text += ColorManager.getColorString(colorCode);
|
||||
colorCode = "x";
|
||||
} else
|
||||
colorCode += args; // a color by itself
|
||||
colorCode += args;
|
||||
} else {
|
||||
waiting = false;
|
||||
if (!colorCode.isEmpty()) {
|
||||
|
||||
@@ -38,9 +38,9 @@ public class ChatItemCommand implements CommandExecutor, TabExecutor {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 0) {
|
||||
Messages.sendMessage(p, "chatitem-cmd.help");
|
||||
} else if (args[0].equalsIgnoreCase("admin")) {
|
||||
} else if (args[0].equalsIgnoreCase("admin") && p.hasPermission("chatitem.reload")) {
|
||||
InventoryListener.open(p);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
} else if (args[0].equalsIgnoreCase("reload") && p.hasPermission("chatitem.reload")) {
|
||||
ChatItem.reload(sender);
|
||||
} else if (args[0].equalsIgnoreCase("show")) {
|
||||
Player cible = args.length == 1 ? p : Bukkit.getPlayer(args[1]);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package me.dadus33.chatitem.hook.ecoenchants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
|
||||
public class EcoEnchantsSupport {
|
||||
|
||||
private static int supportedVersion = 0;
|
||||
|
||||
public static boolean hasSupport() {
|
||||
return supportedVersion > 0;
|
||||
}
|
||||
|
||||
public static boolean load() {
|
||||
String ver = Bukkit.getPluginManager().getPlugin("EcoEnchants").getDescription().getVersion();
|
||||
if(ver.startsWith("8."))
|
||||
supportedVersion = 8;
|
||||
else if(ver.startsWith("10."))
|
||||
supportedVersion = 10;
|
||||
else {
|
||||
ChatItem.getInstance().getLogger().info("Failed to find support version for EcoEnchants " + ver);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack manageItem(ItemStack item) {
|
||||
if(supportedVersion == 8) {
|
||||
List<String> addLore = EcoEnchantsV8Support.getLores(item);
|
||||
if (!addLore.isEmpty()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List<String> lores = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
for (int i = 0; i < addLore.size(); i++)
|
||||
lores.add(i, addLore.get(i));
|
||||
|
||||
meta.setLore(lores);
|
||||
item.setItemMeta(meta);
|
||||
ChatItem.debug("Added " + addLore.size() + " lores from EcoEnchants");
|
||||
} else
|
||||
ChatItem.debug("No lore to add from EcoEnchants");
|
||||
} else if(supportedVersion == 10) {
|
||||
EcoEnchantsV10Support.display(item);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.dadus33.chatitem.hook.ecoenchants;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.willfp.eco.core.display.DisplayProperties;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
|
||||
public class EcoEnchantsV10Support {
|
||||
|
||||
private static EnchantDisplay enchantDisplay;
|
||||
|
||||
public static EnchantDisplay getEnchantDisplay() {
|
||||
if (enchantDisplay == null) {
|
||||
try {
|
||||
enchantDisplay = EnchantDisplay.class.getConstructor(EcoEnchantsPlugin.class).newInstance(EcoEnchantsPlugin.getInstance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return enchantDisplay;
|
||||
}
|
||||
|
||||
public static void display(ItemStack item) {
|
||||
try {
|
||||
DisplayProperties display = DisplayProperties.class.getDeclaredConstructor(boolean.class, boolean.class, ItemStack.class).newInstance(false, false, item);
|
||||
getEnchantDisplay().display(item, (Player) null, display, new Object[] { false });
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package me.dadus33.chatitem.hook;
|
||||
package me.dadus33.chatitem.hook.ecoenchants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.willfp.ecoenchants.display.EnchantmentCache;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
|
||||
public class EcoEnchantsSupport {
|
||||
public class EcoEnchantsV8Support {
|
||||
|
||||
public static List<String> getLores(ItemStack item) {
|
||||
List<String> lores = new ArrayList<>();
|
||||
@@ -1,10 +1,12 @@
|
||||
package me.dadus33.chatitem.playernamer;
|
||||
|
||||
import me.dadus33.chatitem.playernamer.hook.HexNicksV3PlayerNamer;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.playernamer.hook.DefaultPlayerNamer;
|
||||
import me.dadus33.chatitem.playernamer.hook.HexNicksPlayerNamer;
|
||||
import me.dadus33.chatitem.playernamer.hook.HexNicksV2PlayerNamer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PlayerNamerManager {
|
||||
|
||||
@@ -17,11 +19,24 @@ public class PlayerNamerManager {
|
||||
}
|
||||
|
||||
public static void load(ChatItem pl) {
|
||||
if(Bukkit.getPluginManager().getPlugin("HexNicks") != null) {
|
||||
setPlayerNamer(new HexNicksPlayerNamer());
|
||||
pl.getLogger().info("Enable support for HexNicks plugin !");
|
||||
} else {
|
||||
setPlayerNamer(new DefaultPlayerNamer());
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("HexNicks");
|
||||
|
||||
|
||||
if (plugin != null) {
|
||||
char majorVersion = plugin.getDescription().getVersion().charAt(0);
|
||||
|
||||
if (majorVersion == '3')
|
||||
setPlayerNamer(new HexNicksV3PlayerNamer());
|
||||
else
|
||||
setPlayerNamer(new HexNicksV2PlayerNamer());
|
||||
|
||||
pl.getLogger().info("Enable support for HexNicks plugin v" + majorVersion);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
setPlayerNamer(new DefaultPlayerNamer());
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import me.dadus33.chatitem.playernamer.IPlayerNamer;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
public class HexNicksPlayerNamer implements IPlayerNamer {
|
||||
public class HexNicksV2PlayerNamer implements IPlayerNamer {
|
||||
|
||||
@Override
|
||||
public BaseComponent[] getName(Player p) {
|
||||
@@ -0,0 +1,17 @@
|
||||
package me.dadus33.chatitem.playernamer.hook;
|
||||
|
||||
import dev.majek.hexnicks.HexNicks;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.dadus33.chatitem.playernamer.IPlayerNamer;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
public class HexNicksV3PlayerNamer implements IPlayerNamer {
|
||||
|
||||
@Override
|
||||
public BaseComponent[] getName(Player p) {
|
||||
return BungeeComponentSerializer.get().serialize(HexNicks.api().getStoredNick(p).join());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -138,10 +138,7 @@ public class PacketUtils {
|
||||
public static Object getPlayerConnection(Player p) {
|
||||
try {
|
||||
Object entityPlayer = getEntityPlayer(p);
|
||||
if (Version.getVersion().isNewerOrEquals(Version.V1_17))
|
||||
return entityPlayer.getClass().getField("b").get(entityPlayer);
|
||||
else
|
||||
return entityPlayer.getClass().getField("playerConnection").get(entityPlayer);
|
||||
return ReflectionUtils.getFirstWith(entityPlayer, entityPlayer.getClass(), getNmsClass("PlayerConnection", "server.network."));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
@@ -181,6 +178,8 @@ public class PacketUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static Method getNbtMethod;
|
||||
|
||||
/**
|
||||
* Converts an {@link org.bukkit.inventory.ItemStack} to a Json string for
|
||||
* sending with {@link net.md_5.bungee.api.chat.BaseComponent}'s.
|
||||
@@ -190,11 +189,21 @@ public class PacketUtils {
|
||||
*/
|
||||
public static String getNbtTag(ItemStack item) {
|
||||
try {
|
||||
Object nmsStack = JSONManipulator.AS_NMS_COPY.invoke(null, item);
|
||||
Version v = Version.getVersion();
|
||||
Object tag = getNmsClass("ItemStack", "world.item.")
|
||||
.getMethod(v.equals(Version.V1_18) ? "t" : (v.isNewerOrEquals(Version.V1_19) ? "u" : "getTag"))
|
||||
.invoke(nmsStack);
|
||||
if(getNbtMethod == null) {
|
||||
Class<?> itemClass = getNmsClass("ItemStack", "world.item.");
|
||||
Version v = Version.getVersion();
|
||||
if(v.isNewerOrEquals(Version.V1_20))
|
||||
getNbtMethod = itemClass.getDeclaredMethod("w");
|
||||
else if(v.equals(Version.V1_19))
|
||||
getNbtMethod = itemClass.getDeclaredMethod("u");
|
||||
else if(v.equals(Version.V1_18))
|
||||
getNbtMethod = itemClass.getDeclaredMethod("t");
|
||||
else
|
||||
getNbtMethod = itemClass.getDeclaredMethod("getTag");
|
||||
|
||||
getNbtMethod.setAccessible(true);
|
||||
}
|
||||
Object tag = getNbtMethod.invoke(JSONManipulator.AS_NMS_COPY.invoke(null, item));
|
||||
return tag == null ? "{}" : tag.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -9,19 +9,20 @@ import me.dadus33.chatitem.ChatItem;
|
||||
public enum Version {
|
||||
|
||||
// http://wiki.vg/Protocol_version_numbers
|
||||
V1_7(0, 5, 0),
|
||||
V1_8(6, 47, 1),
|
||||
V1_9(49, 110, 2), // 1.9.X - Starts with 49 as 48 was an april fools update
|
||||
V1_10(201, 210, 3), // 1.10.X - Starts with 201 because why not.
|
||||
V1_11(301, 316, 4),
|
||||
V1_12(317, 340, 5),
|
||||
V1_13(341, 440, 6),
|
||||
V1_14(100, 441, 500),
|
||||
V1_15(100, 550, 578),
|
||||
V1_16(100, 700, 754),
|
||||
V1_17(100, 755, 756),
|
||||
V1_18(100, 757, 758),
|
||||
V1_19(100, 761, 1000),
|
||||
V1_7(0, 5, 7),
|
||||
V1_8(6, 47, 8),
|
||||
V1_9(49, 110, 9), // 1.9.X - Starts with 49 as 48 was an april fools update
|
||||
V1_10(201, 210, 10), // 1.10.X - Starts with 201 because why not.
|
||||
V1_11(301, 316, 11),
|
||||
V1_12(317, 340, 12),
|
||||
V1_13(341, 440, 13),
|
||||
V1_14(441, 500, 14),
|
||||
V1_15(550, 578, 15),
|
||||
V1_16(700, 754, 16),
|
||||
V1_17(755, 756, 17),
|
||||
V1_18(757, 758, 18),
|
||||
V1_19(759, 762, 19),
|
||||
V1_20(763, 1000, 20),
|
||||
HIGHER(Integer.MAX_VALUE, -1, Integer.MAX_VALUE);
|
||||
|
||||
// Latest version should always have the upper limit set to Integer.MAX_VALUE so
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Config for ChatItem
|
||||
# For info visit
|
||||
# Spigotmc: https://www.spigotmc.org/resources/chatitem.19064/
|
||||
# Discord: https://discord.gg/ttA5CjMhk7
|
||||
# Spigotmc: https://www.spigotmc.org/resources/19064/
|
||||
# Discord: https://discord.gg/yng5PPf62h
|
||||
|
||||
# Version info, DON'T TOUCH
|
||||
config-version: 13
|
||||
@@ -89,10 +89,10 @@ general:
|
||||
cooldown: 60
|
||||
# All items that are not allowed to be showed
|
||||
ignored_items:
|
||||
- "AIR"
|
||||
- "SOME_ITEM"
|
||||
# Check if the plugin have update
|
||||
check-update: true
|
||||
language: "en_us"
|
||||
language: "en_gb"
|
||||
|
||||
|
||||
# Messages section. You can disable any of them by simply leaving them empty, like this: ""
|
||||
|
||||
@@ -13,7 +13,6 @@ commands:
|
||||
permission: chatitem.reload
|
||||
chatitem:
|
||||
description: See and edit ChatItem informations
|
||||
permission: chatitem.reload
|
||||
permissions:
|
||||
chatitem.reload:
|
||||
description: Allows reloading the config
|
||||
|
||||
Reference in new issue
Block a user