Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a310e3f60 | ||
|
|
58c5f4607f | ||
|
|
b436c73f47 | ||
|
|
806ceea250 | ||
|
|
9a4ef0fe5b | ||
|
|
241f80ca3c | ||
|
|
710bbf3163 | ||
|
|
4ee561c18f | ||
|
|
17754f2dfe | ||
|
|
6a683508d4 | ||
|
|
bcc8ac08f2 | ||
|
|
429a664e81 | ||
|
|
49dadb897a | ||
|
|
3cf54d39a1 | ||
|
|
187d1212f5 | ||
|
|
d3776e161f | ||
|
|
010ea46ff2 | ||
|
|
db8119affd | ||
|
|
484a6b46a0 | ||
|
|
a48f259b99 | ||
|
|
2b9ae264fd | ||
|
|
207b066ecb | ||
|
|
587432269a | ||
|
|
a080e18571 | ||
|
|
7b758882be | ||
|
|
beafc6a635 | ||
|
|
0da4039b70 | ||
|
|
b89e18b149 | ||
|
|
07243fbf91 | ||
|
|
4b90aaa070 | ||
|
|
9d74eb067a | ||
|
|
c51f62a9fb | ||
|
|
badddd29ed | ||
|
|
d188289e84 | ||
|
|
1b9fd3bf90 | ||
|
|
0d98b4408e | ||
|
|
769abab65c | ||
|
|
78311f60b4 | ||
|
|
bd31b5791c | ||
|
|
cd5cfa47ec | ||
|
|
d31bdbef68 | ||
|
|
a82b50b1d0 | ||
|
|
912bbcf371 | ||
|
|
af5d63ea93 | ||
|
|
69681553c8 | ||
|
|
3f6856ddab | ||
|
|
9d55208563 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.dadus33</groupId>
|
||||
<artifactId>ChatItem</artifactId>
|
||||
<version>2.4.8</version>
|
||||
<version>2.5</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</version>
|
||||
<version>5.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.9.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -134,7 +134,7 @@
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
@@ -151,13 +151,7 @@
|
||||
<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>
|
||||
<version>5.9.5</version>
|
||||
<version>12.2.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -169,7 +163,7 @@
|
||||
<dependency>
|
||||
<groupId>com.willfp</groupId>
|
||||
<artifactId>eco</artifactId>
|
||||
<version>6.65.2</version>
|
||||
<version>6.66.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -212,8 +206,8 @@
|
||||
<shadedPattern>me.dadus33.libs.gson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure.text.serializer.bungeecord</pattern>
|
||||
<shadedPattern>me.dadus33.libs.kyori.serializer.bungeecord</shadedPattern>
|
||||
<pattern>com.github.steveice10.opennbt</pattern>
|
||||
<shadedPattern>me.dadus33.libs.opennbt</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -18,6 +19,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import me.dadus33.chatitem.chatmanager.ChatEventListener;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.PacketEditingChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v2.ChatListenerChatManager;
|
||||
@@ -69,6 +71,9 @@ public class ChatItem extends JavaPlugin {
|
||||
if (getInstance().getStorage().debug)
|
||||
getInstance().getLogger().info("[Debug] " + msg.replace(ChatManager.SEPARATOR, 'S').replace(ChatManager.SEPARATOR_END, 'E'));
|
||||
}
|
||||
public static boolean hasDebug() {
|
||||
return getInstance().getStorage().debug;
|
||||
}
|
||||
|
||||
private void chooseManagers() {
|
||||
this.chatManager.forEach((cm) -> cm.unload(this));
|
||||
@@ -145,6 +150,7 @@ public class ChatItem extends JavaPlugin {
|
||||
pm.registerEvents(new JoinListener(), this);
|
||||
pm.registerEvents(new InventoryListener(), this);
|
||||
pm.registerEvents(new TranslationInventoryListener(), this);
|
||||
pm.registerEvents(new ChatEventListener(), this);
|
||||
|
||||
chooseManagers();
|
||||
|
||||
@@ -173,7 +179,7 @@ public class ChatItem extends JavaPlugin {
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, brandChannelName, (chan, p, msg) -> ItemPlayer.getPlayer(p).setClientName(new String(msg).substring(1)));
|
||||
|
||||
if (storage.checkUpdate) {
|
||||
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
String urlName = "https://api.spigotmc.org/legacy/update.php?resource=19064";
|
||||
String content = Utils.getFromURL(urlName);
|
||||
if (Strings.isNullOrEmpty(content))
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.dadus33.chatitem;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import me.dadus33.chatitem.listeners.holder.CustomInventoryHolder;
|
||||
import me.dadus33.chatitem.utils.ItemUtils;
|
||||
import me.dadus33.chatitem.utils.Messages;
|
||||
|
||||
public class InventoryShower {
|
||||
|
||||
public static void showInventory(Player p, Player cible) {
|
||||
Inventory inv = Bukkit.createInventory(new CustomInventoryHolder(), 54, Messages.getMessage("inventory.name", "%cible%", cible.getName()));
|
||||
|
||||
for(int i = 0; i < 18; i++)
|
||||
inv.setItem(i, ItemUtils.createItem(ItemUtils.getMaterialWithCompatibility("BROWN_STAINED_GLASS_PANE", "STAINED_GLASS_PANE"), ""));
|
||||
|
||||
inv.setItem(2, ItemUtils.createItem(ItemUtils.getMaterialWithCompatibility("EXPERIENCE_BOTTLE", "EXP_BOTTLE"), "", cible.getLevel() == 0 ? 1 : (cible.getLevel() >= 64 ? 64 : cible.getLevel())));
|
||||
|
||||
PlayerInventory pi = cible.getInventory();
|
||||
inv.setItem(4, pi.getHelmet());
|
||||
inv.setItem(5, pi.getChestplate());
|
||||
inv.setItem(6, pi.getLeggings());
|
||||
inv.setItem(7, pi.getBoots());
|
||||
|
||||
for(int i = 0; i < pi.getContents().length && i < (54 - 18); i++)
|
||||
inv.setItem(i + 18, pi.getContents()[i]);
|
||||
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
public static void showEnderchest(Player p, Player cible) {
|
||||
Inventory ec = cible.getEnderChest();
|
||||
Inventory inv = Bukkit.createInventory(new CustomInventoryHolder(), ec.getSize(), Messages.getMessage("enderchest.name", "%cible%", cible.getName()));
|
||||
ItemStack[] items = ec.getContents();
|
||||
for(int i = 0; i < ec.getSize(); i++)
|
||||
inv.setItem(i, items[i]);
|
||||
p.openInventory(inv);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package me.dadus33.chatitem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
|
||||
public enum ItemSlot {
|
||||
|
||||
HAND(true, "", false),
|
||||
HELMET(false, "helmet", false),
|
||||
CHESTPLATE(false, "chestplate", false),
|
||||
LEGGINGS(false, "leggings", false),
|
||||
BOOTS(false, "boots", false),
|
||||
INVENTORY(false, "inventory", true),
|
||||
ENDERCHEST(false, "enderchest", true);
|
||||
|
||||
private final boolean basic, command;
|
||||
private final String key;
|
||||
|
||||
private ItemSlot(boolean basic, String key, boolean command) {
|
||||
this.basic = basic;
|
||||
this.command = command;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public boolean isBasic() {
|
||||
return basic;
|
||||
}
|
||||
|
||||
public boolean isCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public List<String> getPlaceholders() {
|
||||
return ChatItem.getInstance().getConfig().getStringList(basic ? "general.placeholders" : "general.other-placeholders." + key + ".keys");
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return basic || ChatItem.getInstance().getConfig().getBoolean("general.other-placeholders." + key + ".enabled", true);
|
||||
}
|
||||
|
||||
public boolean isDenyIfNoItem() {
|
||||
return ChatItem.getInstance().getConfig().getBoolean("general" + (basic ? "" : ".other-placeholders." + key) + ".deny-if-no-item", true);
|
||||
}
|
||||
|
||||
public boolean hasPlaceholders(String message) {
|
||||
for (String rep : getPlaceholders()) {
|
||||
if (message.contains(rep)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String replacePlaceholdersToSeparator(String message) {
|
||||
for(String rep : getPlaceholders())
|
||||
message = message.replace(rep, Character.toString(ChatManager.SEPARATOR));
|
||||
return message;
|
||||
}
|
||||
|
||||
public static ItemSlot getItemSlotFromMessage(String message) {
|
||||
for(ItemSlot slot : ItemSlot.values()) {
|
||||
if(slot.isEnabled() && slot.hasPlaceholders(message)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,14 @@ import java.util.stream.Collectors;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class Storage {
|
||||
|
||||
public String handName, nameFormat, amountFormat, commandFormat, manager, permissionName, buggedClientAction, language;
|
||||
public final String messageNoPermission, messageDeny, messageReload, messageCooldown, messageLimit, messageIgnoredItem;
|
||||
public final String SECONDS, minutes, hours;
|
||||
public final String updateMessage, updateHover;
|
||||
public final List<String> placeholders, tooltipHand, tooltipBuggedClient, ignoredItems;
|
||||
public boolean colorIfColored, addAmountForced, letMessageThrough, denyIfNoItem, debug, handDisabled, showNoPermissionMessage, checkUpdate, permissionEnabled;
|
||||
public final List<String> tooltipHand, tooltipBuggedClient, ignoredItems;
|
||||
public boolean colorIfColored, addAmountForced, letMessageThrough, debug, handDisabled, showNoPermissionMessage, checkUpdate, permissionEnabled, cmdBroadcast, cmdShow, discordSrvSendMsg;
|
||||
public int configVersion, limit, cooldown;
|
||||
private FileConfiguration conf;
|
||||
|
||||
@@ -26,14 +24,12 @@ public class Storage {
|
||||
this.manager = conf.getString("manager", "auto");
|
||||
language = conf.getString("general.language", "en_gb");
|
||||
debug = conf.getBoolean("debug", false);
|
||||
placeholders = ImmutableList.copyOf(conf.getStringList("general.placeholders"));
|
||||
nameFormat = color(conf.getString("general.name-format", "&b&l&o{name} {amount}&r"));
|
||||
amountFormat = color(conf.getString("general.amount-format", "x{times}"));
|
||||
commandFormat = color(conf.getString("general.command-format", "&6%name%'s item is %item%"));
|
||||
colorIfColored = conf.getBoolean("general.color-if-already-colored", true);
|
||||
letMessageThrough = conf.getBoolean("general.let-message-through", true);
|
||||
addAmountForced = conf.getBoolean("general.force-add-amount", true);
|
||||
denyIfNoItem = conf.getBoolean("general.deny-if-no-item", false);
|
||||
limit = conf.getInt("general.limit", 8);
|
||||
cooldown = conf.getInt("general.cooldown", 60);
|
||||
showNoPermissionMessage = conf.getBoolean("general.show-no-permission-message.normal", true);
|
||||
@@ -46,6 +42,8 @@ public class Storage {
|
||||
tooltipBuggedClient = conf.getStringList("general.bugged_client.tooltip").stream().map(Storage::color).collect(Collectors.toList());
|
||||
ignoredItems = conf.getStringList("general.ignored_items");
|
||||
checkUpdate = conf.getBoolean("general.check-update", true);
|
||||
cmdShow = conf.getBoolean("general.sub-commands.broadcast", true);
|
||||
cmdBroadcast = conf.getBoolean("general.sub-commands.show", true);
|
||||
messageDeny = color(conf.getString("messages.deny-message", "&c&lYou have no item in hand!"));
|
||||
messageReload = color(conf.getString("messages.reload-success", "&b&lSuccessful reload!"));
|
||||
messageNoPermission = color(conf.getString("messages.no-permission", "&c&lI'm sorry, but you are not allowed to use the placeholder in chat!"));
|
||||
@@ -54,12 +52,12 @@ public class Storage {
|
||||
updateHover = color(conf.getString("messages.join-update.hover", "&6Click to go to spigot page !"));
|
||||
messageLimit = color(conf.getString("messages.limit-message", "&c&lYou can only add 8 item placeholders per message!"));
|
||||
messageIgnoredItem = color(conf.getString("messages.ignored-item", "&cThis item is not allowed to be showed."));
|
||||
discordSrvSendMsg = conf.getBoolean("discord-srv-send-our", true);
|
||||
|
||||
SECONDS = color(conf.getString("messages.seconds", " seconds"));
|
||||
minutes = color(conf.getString("messages.minutes", " minutes"));
|
||||
hours = color(conf.getString("messages.hours", " hours"));
|
||||
colorStringList(tooltipHand);
|
||||
|
||||
}
|
||||
|
||||
public static String color(String s) {
|
||||
|
||||
@@ -34,8 +34,12 @@ public class Translation {
|
||||
allLangsConfig = Utils.copyLoadFile(pl.getDataFolder(), "langs.yml", "langs.yml");
|
||||
|
||||
allLangsConfig.getStringList("all").forEach(langKey -> {
|
||||
JsonObject content = JsonParser.parseReader(new InputStreamReader(pl.getResource("lang/" + langKey + ".json"))).getAsJsonObject();
|
||||
allLangs.put(langKey, content.get("language.name").getAsString() + " (" + content.get("language.region").getAsString() + ")");
|
||||
try {
|
||||
JsonObject content = JsonParser.parseReader(new InputStreamReader(pl.getResource("lang/" + langKey + ".json"))).getAsJsonObject();
|
||||
allLangs.put(langKey, content.get("language.name").getAsString() + " (" + content.get("language.region").getAsString() + ")");
|
||||
} catch (Exception e) {
|
||||
pl.getLogger().severe("Failed to load lang with key " + langKey + " : " + e.getMessage() + " (" + e.getStackTrace()[0].toString() + ")");
|
||||
}
|
||||
});
|
||||
allLangs = allLangs.entrySet().stream().sorted(Entry.comparingByValue()).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
loadLang(pl.getStorage().language);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.ItemPlayer;
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
import me.dadus33.chatitem.utils.Utils;
|
||||
|
||||
public class Chat {
|
||||
@@ -20,8 +21,8 @@ public class Chat {
|
||||
return CHAT.stream().filter(o -> o.getId() == id).findFirst();
|
||||
}
|
||||
}
|
||||
public static Chat create(Player p, String message) {
|
||||
return new Chat(actualId++, p, message);
|
||||
public static Chat create(Player p, String message, ChatAction action) {
|
||||
return new Chat(actualId++, p, message, action);
|
||||
}
|
||||
public static Chat getFrom(String message) {
|
||||
boolean found = false;
|
||||
@@ -42,12 +43,14 @@ public class Chat {
|
||||
private final int id;
|
||||
private final Player p;
|
||||
private final String message;
|
||||
private final ChatAction action;
|
||||
|
||||
public Chat(int id, Player p, String message) {
|
||||
public Chat(int id, Player p, String message, ChatAction action) {
|
||||
this.time = System.currentTimeMillis();
|
||||
this.id = id;
|
||||
this.p = p;
|
||||
this.message = message;
|
||||
this.action = action;
|
||||
CHAT.add(this);
|
||||
}
|
||||
|
||||
@@ -67,6 +70,14 @@ public class Chat {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ItemSlot getSlot() {
|
||||
return action.getSlot();
|
||||
}
|
||||
|
||||
public ChatAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public ItemPlayer getItemPlayer() {
|
||||
return ItemPlayer.getPlayer(getPlayer());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package me.dadus33.chatitem.chatmanager;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
|
||||
public class ChatAction {
|
||||
|
||||
private boolean isItem;
|
||||
private ItemSlot slot;
|
||||
private String command;
|
||||
private ItemStack item;
|
||||
|
||||
public ChatAction(ItemSlot slot, ItemStack item) {
|
||||
this.slot = slot;
|
||||
this.item = item;
|
||||
this.isItem = true;
|
||||
}
|
||||
|
||||
public ChatAction(ItemSlot slot, String command) {
|
||||
this.slot = slot;
|
||||
this.command = command;
|
||||
this.isItem = false;
|
||||
}
|
||||
|
||||
public ItemSlot getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public boolean isItem() {
|
||||
return isItem;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+15
-34
@@ -1,4 +1,4 @@
|
||||
package me.dadus33.chatitem.chatmanager.v1.listeners;
|
||||
package me.dadus33.chatitem.chatmanager;
|
||||
|
||||
import static me.dadus33.chatitem.chatmanager.ChatManager.SEPARATOR;
|
||||
import static me.dadus33.chatitem.chatmanager.ChatManager.SEPARATOR_END;
|
||||
@@ -8,65 +8,46 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.Chat;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.PacketEditingChatManager;
|
||||
import me.dadus33.chatitem.utils.Utils;
|
||||
|
||||
public class ChatEventListener implements Listener {
|
||||
|
||||
private final PacketEditingChatManager manage;
|
||||
|
||||
public ChatEventListener(PacketEditingChatManager manage) {
|
||||
this.manage = manage;
|
||||
}
|
||||
|
||||
public Storage getStorage() {
|
||||
return this.manage.getStorage();
|
||||
private Storage getStorage() {
|
||||
return ChatItem.getInstance().getStorage();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(AsyncPlayerChatEvent e) {
|
||||
if(ChatManager.isTestingEnabled() && !ChatManager.isTesting("packet"))
|
||||
if (ChatManager.isTestingEnabled() && !ChatManager.isTesting("packet"))
|
||||
return;
|
||||
if (ChatManager.containsSeparator(e.getMessage())) { // If the BELL character is found, we have to remove it
|
||||
e.setMessage(ChatManager.removeSeparator(e.getMessage()));
|
||||
}
|
||||
boolean found = false;
|
||||
final String oldMsg = e.getMessage();
|
||||
for (String rep : getStorage().placeholders) {
|
||||
if (oldMsg.contains(rep)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Player p = e.getPlayer();
|
||||
String oldMsg = e.getMessage();
|
||||
ItemSlot slot = ItemSlot.getItemSlotFromMessage(e.getMessage());
|
||||
if (slot == null) {
|
||||
ChatItem.debug("(v1) not found placeholders in: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = e.getPlayer();
|
||||
ItemStack item = ChatManager.getUsableItem(p);
|
||||
if (!ChatManager.canShowItem(p, item, e))
|
||||
ChatAction action = ChatManager.getChatAction(slot, p);
|
||||
if(action.isItem() && !ChatManager.canShowItem(p, action.getItem(), slot, e))
|
||||
return;
|
||||
String s = e.getMessage(), firstPlaceholder = getStorage().placeholders.get(0);
|
||||
for (String placeholder : getStorage().placeholders) {
|
||||
s = s.replace(placeholder, firstPlaceholder);
|
||||
}
|
||||
if (Utils.countMatches(s, firstPlaceholder) > getStorage().limit) {
|
||||
String s = slot.replacePlaceholdersToSeparator(e.getMessage());
|
||||
if (Utils.countMatches(s, Character.toString(ChatManager.SEPARATOR)) > getStorage().limit) {
|
||||
e.setCancelled(true);
|
||||
if (!getStorage().messageLimit.isEmpty())
|
||||
p.sendMessage(getStorage().messageLimit);
|
||||
return;
|
||||
}
|
||||
|
||||
Chat c = Chat.create(p, oldMsg);
|
||||
Chat c = Chat.create(p, oldMsg, action);
|
||||
ChatItem.debug("(v1) Set placeholder to message " + c);
|
||||
e.setMessage(s.replace(firstPlaceholder, SEPARATOR + Integer.toString(c.getId()) + SEPARATOR_END));
|
||||
e.setMessage(s.replace(Character.toString(ChatManager.SEPARATOR), SEPARATOR + Integer.toString(c.getId()) + SEPARATOR_END));
|
||||
e.setFormat(e.getFormat().replace(oldMsg, e.getMessage())); // set own message for plugin that already put the message into the format
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.hook.ecoenchants.EcoEnchantsSupport;
|
||||
import me.dadus33.chatitem.itemnamer.NamerManager;
|
||||
@@ -90,15 +91,24 @@ public abstract class ChatManager {
|
||||
* @param p the player
|
||||
* @return the usable item
|
||||
*/
|
||||
public static ItemStack getUsableItem(Player p) {
|
||||
ItemStack item = HandItem.getBetterItem(p).clone();
|
||||
|
||||
public static ItemStack getUsableItem(Player p, ItemSlot slot) {
|
||||
if(slot == null)
|
||||
return null;
|
||||
ItemStack item = HandItem.getBetterItem(p, slot).clone();
|
||||
if(slot.isDenyIfNoItem() && ItemUtils.isEmpty(item))
|
||||
return null;
|
||||
if (EcoEnchantsSupport.hasSupport()) {
|
||||
item = EcoEnchantsSupport.manageItem(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ChatAction getChatAction(ItemSlot slot, Player p) {
|
||||
if(slot.isCommand()) {
|
||||
return new ChatAction(slot, "/chatitem seeinv " + slot.name().toLowerCase() + " " + p.getUniqueId());
|
||||
}
|
||||
return new ChatAction(slot, getUsableItem(p, slot));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all lores lines of an item, to replace the show_item action which is not
|
||||
@@ -149,18 +159,7 @@ public abstract class ChatManager {
|
||||
amount = amount.replace(TIMES, String.valueOf(item.getAmount()));
|
||||
replacer = replacer.replace(AMOUNT, amount);
|
||||
}
|
||||
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
|
||||
String trp = item.getItemMeta().getDisplayName();
|
||||
ChatItem.debug("trp: " + trp);
|
||||
if (c.colorIfColored) {
|
||||
replacer = replacer.replace(NAME, ChatColor.stripColor(trp));
|
||||
} else {
|
||||
replacer = replacer.replace(NAME, trp);
|
||||
}
|
||||
} else {
|
||||
replacer = replacer.replace(NAME, NamerManager.getName(p, item, c));
|
||||
}
|
||||
return replacer;
|
||||
return replacer.replace(NAME, NamerManager.getName(p, item, c));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,12 +173,26 @@ public abstract class ChatManager {
|
||||
public static String getNameOfItem(Player p, ItemStack item, Storage c) {
|
||||
if (ItemUtils.isEmpty(item)) {
|
||||
if (c.handDisabled)
|
||||
return c.placeholders.get(0);
|
||||
return ItemSlot.HAND.getPlaceholders().get(0);
|
||||
else
|
||||
return c.handName;
|
||||
}
|
||||
return styleItem(p, item, c);
|
||||
}
|
||||
|
||||
public static String getNameForChatAction(Player p, ChatAction action, Storage c) {
|
||||
if(action.isItem()) {
|
||||
ItemStack item = action.getItem();
|
||||
if (ItemUtils.isEmpty(item)) {
|
||||
if (c.handDisabled)
|
||||
return ItemSlot.HAND.getPlaceholders().get(0);
|
||||
else
|
||||
return c.handName;
|
||||
}
|
||||
return styleItem(p, item, c);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculateTime(long seconds) {
|
||||
Storage c = ChatItem.getInstance().getStorage();
|
||||
@@ -210,7 +223,9 @@ public abstract class ChatManager {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static boolean canShowItem(Player p, ItemStack item, @Nullable Cancellable e) {
|
||||
public static boolean canShowItem(Player p, ItemStack item, ItemSlot slot, @Nullable Cancellable e) {
|
||||
if(item == null)
|
||||
return false;
|
||||
Storage c = ChatItem.getInstance().getStorage();
|
||||
if (c.permissionEnabled && !p.hasPermission(c.permissionName)) {
|
||||
if (!c.letMessageThrough) {
|
||||
@@ -223,7 +238,7 @@ public abstract class ChatManager {
|
||||
return false;
|
||||
}
|
||||
if (item.getType().equals(Material.AIR)) {
|
||||
if (c.denyIfNoItem) {
|
||||
if (slot.isDenyIfNoItem()) {
|
||||
if (e != null)
|
||||
e.setCancelled(true);
|
||||
if (!c.messageDeny.isEmpty())
|
||||
|
||||
@@ -3,20 +3,36 @@ package me.dadus33.chatitem.chatmanager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
import me.dadus33.chatitem.utils.ItemUtils;
|
||||
import me.dadus33.chatitem.utils.Version;
|
||||
|
||||
public class HandItem {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ItemStack getBetterItem(Player p) {
|
||||
if(Version.getVersion().isNewerOrEquals(Version.V1_9)) {
|
||||
ItemStack main = p.getInventory().getItemInMainHand();
|
||||
if(!ItemUtils.isEmpty(main))
|
||||
return main;
|
||||
ItemStack off = p.getInventory().getItemInOffHand();
|
||||
return ItemUtils.isEmpty(off) ? main : off;
|
||||
public static ItemStack getBetterItem(Player p, ItemSlot slot) {
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
if(Version.getVersion().isNewerOrEquals(Version.V1_9)) {
|
||||
ItemStack main = p.getInventory().getItemInMainHand();
|
||||
if(!ItemUtils.isEmpty(main))
|
||||
return main;
|
||||
return p.getInventory().getItemInOffHand();
|
||||
}
|
||||
return p.getItemInHand();
|
||||
case HELMET:
|
||||
return p.getInventory().getHelmet();
|
||||
case CHESTPLATE:
|
||||
return p.getInventory().getChestplate();
|
||||
case LEGGINGS:
|
||||
return p.getInventory().getLeggings();
|
||||
case BOOTS:
|
||||
return p.getInventory().getBoots();
|
||||
case ENDERCHEST:
|
||||
break;
|
||||
case INVENTORY:
|
||||
break;
|
||||
}
|
||||
return p.getItemInHand();
|
||||
return null; // should never happen
|
||||
}
|
||||
}
|
||||
@@ -3,27 +3,25 @@ package me.dadus33.chatitem.chatmanager.v1;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.listeners.ChatEventListener;
|
||||
import me.dadus33.chatitem.chatmanager.v1.listeners.ChatPacketManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.ChatItemPacketManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.PacketManager;
|
||||
import me.dadus33.chatitem.utils.PacketUtils;
|
||||
import me.dadus33.chatitem.utils.ReflectionUtils;
|
||||
import me.dadus33.chatitem.utils.Utils;
|
||||
|
||||
public class PacketEditingChatManager extends ChatManager {
|
||||
|
||||
private boolean baseComponentAvailable = true;
|
||||
private final ChatItemPacketManager packetManager;
|
||||
private final ChatEventListener chatEventListener;
|
||||
private final ChatPacketManager chatPacketManager;
|
||||
|
||||
public PacketEditingChatManager(ChatItem pl) {
|
||||
packetManager = new ChatItemPacketManager(pl);
|
||||
chatEventListener = new ChatEventListener(this);
|
||||
chatPacketManager = new ChatPacketManager(this);
|
||||
|
||||
// Check for existence of BaseComponent class (only on spigot)
|
||||
@@ -48,7 +46,6 @@ public class PacketEditingChatManager extends ChatManager {
|
||||
public void load(ChatItem pl, Storage s) {
|
||||
super.load(pl, s);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(chatEventListener, pl);
|
||||
PacketManager pm = packetManager.getPacketManager();
|
||||
pm.addHandler(chatPacketManager);
|
||||
Bukkit.getOnlinePlayers().forEach(pm::addPlayer); // add actual online players
|
||||
@@ -56,7 +53,6 @@ public class PacketEditingChatManager extends ChatManager {
|
||||
|
||||
@Override
|
||||
public void unload(ChatItem pl) {
|
||||
HandlerList.unregisterAll(chatEventListener);
|
||||
PacketManager pm = packetManager.getPacketManager();
|
||||
pm.removeHandler(chatPacketManager);
|
||||
pm.stop();
|
||||
@@ -78,7 +74,8 @@ public class PacketEditingChatManager extends ChatManager {
|
||||
}
|
||||
|
||||
private static Object internalCreateSystemChatPacket(Object obj) throws Exception {
|
||||
Class<?> packetClass = PacketUtils.getNmsClass("ClientboundSystemChatPacket", "network.protocol.game.", "PacketPlayOutChat");
|
||||
Class<?> packetClass = PacketUtils.getNmsClass("ClientboundPlayerChatPacket", "network.protocol.game.", "ClientboundSystemChatPacket", "PacketPlayOutChat");
|
||||
Class<?> chatMessageTypeClass = PacketUtils.isClassExist("net.minecraft.network.chat.ChatMessageType") ? PacketUtils.getNmsClass("ChatMessageType", "network.chat.") : null;
|
||||
Constructor<?> betterOne = null;
|
||||
Object[] betterParam = null;
|
||||
for (Constructor<?> cons : packetClass.getDeclaredConstructors()) {
|
||||
@@ -89,6 +86,8 @@ public class PacketEditingChatManager extends ChatManager {
|
||||
if(obj instanceof String) {
|
||||
if (cons.getParameterCount() == 2 && cons.getParameterTypes()[0].equals(String.class) && cons.getParameterTypes()[1].equals(int.class)) { // "string, int"
|
||||
return cons.newInstance(obj, 1);
|
||||
} else if (cons.getParameterCount() == 2 && cons.getParameterTypes()[0].equals(String.class) && cons.getParameterTypes()[1].equals(boolean.class)) { // "string, boolean"
|
||||
return cons.newInstance(obj, false); // false for no overlay
|
||||
} else if (cons.getParameterCount() == 3 && cons.getParameterTypes()[1].equals(String.class)) { // "component", "string", <something not checked>
|
||||
Class<?> secondParam = cons.getParameterTypes()[2];
|
||||
if (secondParam.equals(int.class)) // "component", "string", "int"
|
||||
@@ -104,7 +103,12 @@ public class PacketEditingChatManager extends ChatManager {
|
||||
if(cons.getParameterTypes()[i].isAssignableFrom(obj.getClass())) {
|
||||
params[i] = obj;
|
||||
nbPut++;
|
||||
}
|
||||
} else if(chatMessageTypeClass != null && cons.getParameterTypes()[i].isAssignableFrom(chatMessageTypeClass)) {
|
||||
params[i] = getChatMessageType();
|
||||
} else if(cons.getParameterTypes()[i].isAssignableFrom(boolean.class)) // need to set primitives
|
||||
params[i] = false;
|
||||
else if(cons.getParameterTypes()[i].isAssignableFrom(int.class)) // need to set primitives
|
||||
params[i] = 0;
|
||||
}
|
||||
if(nbPut == 1) {
|
||||
if((betterOne == null && betterParam == null) || betterParam.length > params.length) {
|
||||
@@ -118,8 +122,18 @@ public class PacketEditingChatManager extends ChatManager {
|
||||
ChatItem.getInstance().getLogger().warning("Some constructor seems to have too many " + obj.getClass().getSimpleName() + ". Class: " + packetClass.getSimpleName());
|
||||
}
|
||||
if(betterOne != null && betterParam != null) {
|
||||
return betterOne.newInstance(betterParam);
|
||||
try {
|
||||
return betterOne.newInstance(betterParam);
|
||||
} catch (IllegalArgumentException e) {
|
||||
ChatItem.getInstance().getLogger().warning("Failed to create a new packet to send. " + betterOne.getParameterCount() + " (" + Utils.arrayToString(betterOne.getParameterTypes()) + "). Params: " + Utils.arrayToString(betterParam));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Object getChatMessageType() throws Exception {
|
||||
Class<?> c = PacketUtils.getNmsClass("ChatMessageType", "network.chat.");
|
||||
return ReflectionUtils.getMethod(c, c, byte.class).invoke(null, (byte) 0);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.ItemPlayer;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.Chat;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
@@ -45,9 +44,12 @@ public interface IComponentManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, Storage c) throws Exception {
|
||||
String message = JSONManipulator.getInstance().parse(chat, getBaseComponentAsJSON(packet), item, ChatManager.styleItem(chat.getPlayer(), item, c),
|
||||
ItemPlayer.getPlayer(p).getProtocolVersion());
|
||||
default Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, String json, Storage c) throws Exception {
|
||||
String message;
|
||||
if (Utils.isBeforeChatJson(p))
|
||||
message = JSONManipulator.getInstance().parseEmpty(json, ChatManager.styleItem(chat.getPlayer(), item, c), ChatManager.getMaxLinesFromItem(p, item), chat.getPlayer());
|
||||
else
|
||||
message = JSONManipulator.getInstance().parse(chat, json, chat.getAction(), ChatManager.styleItem(chat.getPlayer(), item, c));
|
||||
if (message != null) {
|
||||
ChatItem.debug("(v1) Writing message: " + message);
|
||||
writeJson(packet, message);
|
||||
@@ -55,8 +57,8 @@ public interface IComponentManager {
|
||||
return packet.getPacket();
|
||||
}
|
||||
|
||||
default Object manageEmpty(Player p, Chat chat, ChatItemPacket packet, Storage c) {
|
||||
String message = JSONManipulator.getInstance().parseEmpty(getBaseComponentAsJSON(packet), c.handName, c.tooltipHand, chat.getPlayer());
|
||||
default Object manageEmpty(Player p, Chat chat, ChatItemPacket packet, String json, Storage c) {
|
||||
String message = JSONManipulator.getInstance().parseEmpty(json, c.handName, c.tooltipHand, chat.getPlayer());
|
||||
if (message != null) {
|
||||
ChatItem.debug("(v1) Writing empty message: " + message);
|
||||
writeJson(packet, message);
|
||||
@@ -82,11 +84,11 @@ public interface IComponentManager {
|
||||
}
|
||||
if (jsonObj.has("text")) {
|
||||
JsonElement text = jsonObj.get("text");
|
||||
if(text.isJsonObject() && searchInObject(text.getAsJsonObject()))
|
||||
if (text.isJsonObject() && searchInObject(text.getAsJsonObject()))
|
||||
return getWithId();
|
||||
else if(text.isJsonArray() && searchInExtra(text.getAsJsonArray()))
|
||||
else if (text.isJsonArray() && searchInExtra(text.getAsJsonArray()))
|
||||
return getWithId();
|
||||
else if(text.isJsonPrimitive() && searchInString(text.getAsString()))
|
||||
else if (text.isJsonPrimitive() && searchInString(text.getAsString()))
|
||||
return getWithId();
|
||||
}
|
||||
return null;
|
||||
@@ -122,7 +124,7 @@ public interface IComponentManager {
|
||||
else if (found)
|
||||
id += c;
|
||||
}
|
||||
return false;
|
||||
return id != "" && Utils.isInteger(id) && Chat.getChat(Integer.parseInt(id)).isPresent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
-18
@@ -14,18 +14,22 @@ import com.google.gson.JsonParser;
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.Chat;
|
||||
import me.dadus33.chatitem.chatmanager.ChatAction;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.PacketEditingChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.IComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.ChatItemPacket;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.PacketContent.ContentModifier;
|
||||
import me.dadus33.chatitem.hook.DiscordSrvSupport;
|
||||
import me.dadus33.chatitem.utils.Messages;
|
||||
import me.dadus33.chatitem.utils.PacketUtils;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.nbt.api.BinaryTagHolder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
public class AdventureComponentManager implements IComponentManager {
|
||||
@@ -34,16 +38,17 @@ public class AdventureComponentManager implements IComponentManager {
|
||||
public boolean hasConditions() {
|
||||
try {
|
||||
for (String cl : Arrays.asList("net.kyori.adventure.text.Component", "net.kyori.adventure.text.serializer.gson.GsonComponentSerializer"))
|
||||
Class.forName(cl);
|
||||
Class.forName(cl);
|
||||
} catch (Throwable e) { // can't support this, adventure comp not found
|
||||
ChatItem.debug("Can't load AdventureComponentManager : " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeJson(ChatItemPacket packet, String json) {}
|
||||
public void writeJson(ChatItemPacket packet, String json) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseComponentAsJSON(ChatItemPacket packet) {
|
||||
@@ -66,57 +71,77 @@ public class AdventureComponentManager implements IComponentManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, Storage c) throws Exception {
|
||||
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))));
|
||||
public Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, String json, Storage c) throws Exception {
|
||||
ChatAction action = chat.getAction();
|
||||
if (action.isItem()) {
|
||||
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))), null);
|
||||
}
|
||||
return manage(p, chat, packet, Messages.getMessage(action.getSlot().name().toLowerCase() + ".chat", "%cible%", chat.getPlayer().getName()),
|
||||
HoverEvent.showText(Component.text(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover", "%cible%", chat.getPlayer().getName()))),
|
||||
ClickEvent.runCommand(action.getCommand()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object manageEmpty(Player p, Chat chat, ChatItemPacket packet, Storage c) {
|
||||
public Object manageEmpty(Player p, Chat chat, ChatItemPacket packet, String json, Storage c) {
|
||||
Component builder = Component.text("");
|
||||
c.tooltipHand.forEach(s -> builder.append(Component.text(s)));
|
||||
Player sender = chat.getPlayer();
|
||||
String handName = c.handName.replace("{name}", sender.getName()).replace("{display-name}", sender.getDisplayName());
|
||||
return manage(p, chat, packet, handName, HoverEvent.showText(builder));
|
||||
ChatAction action = chat.getAction();
|
||||
if (action.isItem()) {
|
||||
String handName = c.handName.replace("{name}", sender.getName()).replace("{display-name}", sender.getDisplayName());
|
||||
return manage(p, chat, packet, handName, HoverEvent.showText(builder), null);
|
||||
}
|
||||
return manage(p, chat, packet, Messages.getMessage(action.getSlot().name().toLowerCase() + ".chat", "%cible%", chat.getPlayer().getName()),
|
||||
HoverEvent.showText(Component.text(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover", "%cible%", chat.getPlayer().getName()))),
|
||||
ClickEvent.runCommand(action.getCommand()));
|
||||
}
|
||||
|
||||
private Object manage(Player p, Chat chat, ChatItemPacket packet, String replacement, HoverEvent<?> hover) {
|
||||
private Object manage(Player p, Chat chat, ChatItemPacket packet, String replacement, HoverEvent<?> hover, ClickEvent click) {
|
||||
ContentModifier<Component> modifier = packet.getContent().getSpecificModifier(Component.class);
|
||||
Component comp = modifier.readSafely(0);
|
||||
if (comp == null) {
|
||||
ChatItem.debug("The component is null.");
|
||||
return null;
|
||||
}
|
||||
comp = checkComponent(comp, hover, replacement, chat);
|
||||
comp = checkComponent(comp, hover, click, replacement, chat);
|
||||
if(ChatItem.discordSrvSupport && DiscordSrvSupport.isSendingMessage())
|
||||
DiscordSrvSupport.sendChatMessage(p, comp, null);
|
||||
ChatItem.debug("Result: " + GsonComponentSerializer.gson().serialize(comp));
|
||||
try {
|
||||
packet.getContent().getSpecificModifier(Component.class).write(0, comp);
|
||||
/*try {
|
||||
packet.setPacket(PacketEditingChatManager.createSystemChatPacket(GsonComponentSerializer.gson().serialize(comp)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
return packet.getPacket();
|
||||
}
|
||||
|
||||
private Component checkComponent(Component comp, HoverEvent<?> hover, String itemName, Chat chat) {
|
||||
private Component checkComponent(Component comp, HoverEvent<?> hover, ClickEvent click, String itemName, Chat chat) {
|
||||
if (comp instanceof TextComponent) {
|
||||
TextComponent tc = (TextComponent) comp;
|
||||
if (ChatManager.containsSeparator(tc.content())) {
|
||||
ChatItem.debug("Changing text " + tc.content() + " to " + itemName);
|
||||
TextColor color = tc.color();
|
||||
comp = tc.content(ChatManager.replaceSeparator(chat, tc.content(), itemName)).hoverEvent(hover);
|
||||
if (click != null)
|
||||
comp.clickEvent(click);
|
||||
comp.append(Component.text("").color(color)); // reset color
|
||||
} else
|
||||
ChatItem.debug("No insert of text without separator: " + tc.content());
|
||||
} else if(comp instanceof TranslatableComponent) {
|
||||
} else if (comp instanceof TranslatableComponent) {
|
||||
TranslatableComponent tc = (TranslatableComponent) comp;
|
||||
List<Component> next = new ArrayList<>();
|
||||
for (Component extra : tc.args()) {
|
||||
next.add(checkComponent(extra, hover, itemName, chat));
|
||||
next.add(checkComponent(extra, hover, click, itemName, chat));
|
||||
}
|
||||
comp = tc.args(next);
|
||||
} else
|
||||
ChatItem.debug("Not valid comp class " + comp.getClass().getSimpleName() + " : " + comp);
|
||||
List<Component> next = new ArrayList<>();
|
||||
for (Component extra : comp.children()) {
|
||||
next.add(checkComponent(extra, hover, itemName, chat));
|
||||
next.add(checkComponent(extra, hover, click, itemName, chat));
|
||||
}
|
||||
return comp.children(next);
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,5 +1,7 @@
|
||||
package me.dadus33.chatitem.chatmanager.v1.basecomp.hook;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import me.dadus33.chatitem.chatmanager.v1.PacketEditingChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.IComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.ChatItemPacket;
|
||||
@@ -17,7 +19,10 @@ public class ComponentNMSManager implements IComponentManager {
|
||||
Object chatBaseComp = packet.getContent().getChatComponents().readSafely(0);
|
||||
if (chatBaseComp != null) {
|
||||
try {
|
||||
return PacketUtils.CHAT_SERIALIZER.getMethod("a", PacketUtils.COMPONENT_CLASS).invoke(null, chatBaseComp).toString();
|
||||
Object o = PacketUtils.CHAT_SERIALIZER.getMethod("a", PacketUtils.COMPONENT_CLASS).invoke(null, chatBaseComp);
|
||||
if(o != null && o instanceof String && JsonParser.parseString((String) o).isJsonObject()) {
|
||||
return (String) o;
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
@@ -27,7 +32,12 @@ public class ComponentNMSManager implements IComponentManager {
|
||||
|
||||
@Override
|
||||
public void writeJson(ChatItemPacket packet, String json) {
|
||||
// Not compatible with that for now
|
||||
//if(ChatItem.discordSrvSupport && DiscordSrvSupport.isSendingMessage())
|
||||
// DiscordSrvSupport.sendChatMessage(p, comp, null);
|
||||
try {
|
||||
PacketUtils.printPacketToDebug(packet.getPacket());
|
||||
PacketUtils.printPacketToDebug(PacketEditingChatManager.createSystemChatPacket(json));
|
||||
packet.setPacket(PacketEditingChatManager.createSystemChatPacket(json));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
+36
-9
@@ -13,12 +13,16 @@ import com.google.gson.JsonParser;
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.Chat;
|
||||
import me.dadus33.chatitem.chatmanager.ChatAction;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.PacketEditingChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.basecomp.IComponentManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.ChatItemPacket;
|
||||
import me.dadus33.chatitem.hook.DiscordSrvSupport;
|
||||
import me.dadus33.chatitem.utils.Messages;
|
||||
import me.dadus33.chatitem.utils.Utils;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -60,20 +64,38 @@ public class StringComponentManager implements IComponentManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, Storage c) throws Exception {
|
||||
return manage(p, chat, packet, ChatManager.getNameOfItem(chat.getPlayer(), item, c), Utils.createItemHover(item));
|
||||
public Object manageItem(Player p, Chat chat, ChatItemPacket packet, ItemStack item, String json, Storage c) throws Exception {
|
||||
ChatAction action = chat.getAction();
|
||||
if (action.isItem())
|
||||
return manage(p, chat, packet, ChatManager.getNameOfItem(chat.getPlayer(), item, c), Utils.createItemHover(item, p), null);
|
||||
else
|
||||
return manage(p, chat, packet, ChatManager.getNameOfItem(chat.getPlayer(), item, c),
|
||||
Utils.createTextHover(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover", "%cible%", chat.getPlayer().getName())),
|
||||
Utils.createRunCommand(action.getCommand()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object manageEmpty(Player p, Chat chat, ChatItemPacket packet, Storage c) {
|
||||
public Object manageEmpty(Player p, Chat chat, ChatItemPacket packet, String json, Storage c) {
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
c.tooltipHand.forEach(s -> builder.append(s));
|
||||
Player sender = chat.getPlayer();
|
||||
String handName = c.handName.replace("{name}", sender.getName()).replace("{display-name}", sender.getDisplayName());
|
||||
return manage(p, chat, packet, handName, Utils.createTextHover(builder.create()));
|
||||
HoverEvent hover;
|
||||
ClickEvent click;
|
||||
String rep;
|
||||
ChatAction action = chat.getAction();
|
||||
if (action.isItem()) {
|
||||
hover = Utils.createTextHover(builder.create());
|
||||
rep = c.handName.replace("{name}", sender.getName()).replace("{display-name}", sender.getDisplayName());
|
||||
click = null;
|
||||
} else {
|
||||
hover = Utils.createTextHover(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover", "%cible%", chat.getPlayer().getName()));
|
||||
rep = Messages.getMessage(action.getSlot().name().toLowerCase() + ".chat", "%cible%", chat.getPlayer().getName());
|
||||
click = Utils.createRunCommand(action.getCommand());
|
||||
}
|
||||
return manage(p, chat, packet, rep, hover, click);
|
||||
}
|
||||
|
||||
private Object manage(Player p, Chat chat, ChatItemPacket packet, String replacement, HoverEvent hover) {
|
||||
private Object manage(Player p, Chat chat, ChatItemPacket packet, String replacement, HoverEvent hover, ClickEvent click) {
|
||||
BaseComponent[] components = packet.getContent().getSpecificModifier(BaseComponent[].class).readSafely(0);
|
||||
if (components == null) {
|
||||
String json = packet.getContent().getStrings().readSafely(0);
|
||||
@@ -101,7 +123,10 @@ public class StringComponentManager implements IComponentManager {
|
||||
}
|
||||
}
|
||||
ChatItem.debug("Checking for " + components.length + " components");
|
||||
Arrays.asList(components).forEach(comp -> checkComponent(comp, hover, replacement, chat));
|
||||
Arrays.asList(components).forEach(comp -> checkComponent(comp, hover, click, replacement, chat));
|
||||
|
||||
if(ChatItem.discordSrvSupport && DiscordSrvSupport.isSendingMessage())
|
||||
DiscordSrvSupport.sendChatMessage(p, TextComponent.toLegacyText(components), null);
|
||||
try {
|
||||
packet.setPacket(PacketEditingChatManager.createSystemChatPacket(ComponentSerializer.toString(components)));
|
||||
} catch (Exception e) {
|
||||
@@ -110,7 +135,7 @@ public class StringComponentManager implements IComponentManager {
|
||||
return packet.getPacket();
|
||||
}
|
||||
|
||||
private void checkComponent(BaseComponent comp, HoverEvent hover, String itemName, Chat chat) {
|
||||
private void checkComponent(BaseComponent comp, HoverEvent hover, ClickEvent click, String itemName, Chat chat) {
|
||||
if (comp instanceof TextComponent) {
|
||||
TextComponent tc = (TextComponent) comp;
|
||||
if (ChatManager.containsSeparator(tc.getText())) {
|
||||
@@ -118,12 +143,14 @@ public class StringComponentManager implements IComponentManager {
|
||||
ChatItem.debug("Changing text " + oldText + " to " + itemName + ", extra: " + (tc.getExtra() == null ? "-" : tc.getExtra().size()));
|
||||
tc.setText(ChatManager.replaceSeparator(chat, oldText, itemName));
|
||||
tc.setHoverEvent(hover);
|
||||
if (click != null)
|
||||
tc.setClickEvent(click);
|
||||
} else
|
||||
ChatItem.debug("No insert of text without separator: " + tc.getText() + " (legacy: " + tc.toLegacyText() + ")");
|
||||
}
|
||||
if (comp.getExtra() != null) {
|
||||
for (BaseComponent extra : comp.getExtra()) {
|
||||
checkComponent(extra, hover, itemName, chat);
|
||||
checkComponent(extra, hover, click, itemName, chat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,12 @@ import static me.dadus33.chatitem.utils.PacketUtils.getNmsClass;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -24,10 +21,11 @@ import com.google.gson.JsonPrimitive;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.chatmanager.Chat;
|
||||
import me.dadus33.chatitem.chatmanager.ChatAction;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.utils.Messages;
|
||||
import me.dadus33.chatitem.utils.PacketUtils;
|
||||
import me.dadus33.chatitem.utils.ReflectionUtils;
|
||||
import me.dadus33.chatitem.utils.Version;
|
||||
|
||||
public class JSONManipulator {
|
||||
|
||||
@@ -46,59 +44,61 @@ public class JSONManipulator {
|
||||
public static final Method SAVE_NMS_ITEM_STACK_METHOD = ReflectionUtils.getMethod(NMS_ITEM_STACK_CLASS, NBT_TAG_COMPOUND, NBT_TAG_COMPOUND);
|
||||
public static final Field MAP = ReflectionUtils.getField(NBT_TAG_COMPOUND, "map", "x");
|
||||
|
||||
private static final ConcurrentHashMap<Map.Entry<Version, ItemStack>, JsonObject> STACKS = new ConcurrentHashMap<>();
|
||||
|
||||
private JsonObject itemTooltip;
|
||||
private JsonArray classicTooltip;
|
||||
|
||||
public String parse(Chat chat, String json, ItemStack item, String replacement, int protocol) throws Exception {
|
||||
public String parse(Chat chat, String json, ChatAction action, String replacement) throws Exception {
|
||||
JsonObject obj = JsonParser.parseString(json).getAsJsonObject();
|
||||
final AbstractMap.SimpleEntry<Version, ItemStack> p = new AbstractMap.SimpleEntry<>(Version.getVersion(protocol), item);
|
||||
|
||||
JsonObject wrapper = new JsonObject(); // Create a wrapper object for the whole array
|
||||
if ((itemTooltip = STACKS.get(p)) == null) {
|
||||
JsonArray use = Translator.toJson(replacement); // We get the json representation of the old color
|
||||
// formatting method
|
||||
ChatItem.debug("Remplacement: " + replacement + " use: " + use.toString());
|
||||
// There's no public clone method for JSONObjects so we need to parse them every
|
||||
// time
|
||||
JsonObject hover = new JsonObject();
|
||||
JsonArray use = Translator.toJson(replacement); // We get the json representation of the old color
|
||||
// formatting method
|
||||
ChatItem.debug("Remplacement: " + replacement + " use: " + use.toString());
|
||||
// There's no public clone method for JSONObjects so we need to parse them every
|
||||
// time
|
||||
JsonObject hover = new JsonObject();
|
||||
if (action.isItem()) {
|
||||
hover.addProperty("action", "show_item");
|
||||
|
||||
// Get the JSON representation of the item (well, not really JSON, but rather a
|
||||
// string representation of NBT data)
|
||||
hover.addProperty("value", stringifyItem(item));
|
||||
hover.addProperty("value", stringifyItem(action.getItem()));
|
||||
} else {
|
||||
hover.addProperty("action", "show_text");
|
||||
|
||||
if (use.size() == 1) {
|
||||
JsonElement extraElement = use.get(0);
|
||||
if (extraElement.isJsonPrimitive())
|
||||
wrapper.addProperty("text", extraElement.getAsString());
|
||||
else if (extraElement.isJsonObject())
|
||||
wrapper.addProperty("text", extraElement.getAsJsonObject().get("text").getAsString());
|
||||
else
|
||||
wrapper.add("extra", use); // add it only if
|
||||
} else if (!use.isEmpty())
|
||||
// Get the JSON representation of the item (well, not really JSON, but rather a
|
||||
// string representation of NBT data)
|
||||
hover.addProperty("value", parseEmpty(json, replacement, Arrays.asList(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover")), chat.getPlayer()));
|
||||
|
||||
JsonObject click = new JsonObject();
|
||||
click.addProperty("action", "run_command");
|
||||
click.addProperty("value", action.getCommand());
|
||||
wrapper.add("clickEvent", click);
|
||||
}
|
||||
|
||||
if (use.size() == 1) {
|
||||
JsonElement extraElement = use.get(0);
|
||||
if (extraElement.isJsonPrimitive())
|
||||
wrapper.addProperty("text", extraElement.getAsString());
|
||||
else if (extraElement.isJsonObject())
|
||||
wrapper.addProperty("text", extraElement.getAsJsonObject().get("text").getAsString());
|
||||
else
|
||||
wrapper.add("extra", use); // add it only if
|
||||
if (!wrapper.has("text"))
|
||||
wrapper.addProperty("text", ""); // The text field is compulsory, even if it's empty
|
||||
wrapper.add("hoverEvent", hover);
|
||||
} else if (!use.isEmpty())
|
||||
wrapper.add("extra", use); // add it only if
|
||||
if (!wrapper.has("text"))
|
||||
wrapper.addProperty("text", ""); // The text field is compulsory, even if it's empty
|
||||
wrapper.add("hoverEvent", hover);
|
||||
|
||||
itemTooltip = wrapper; // Save the tooltip for later use when we encounter a placeholder
|
||||
STACKS.put(p, itemTooltip); // Save it in the cache too so when parsing other packets with the same item
|
||||
// (and client version) we no longer have to create it again
|
||||
// We remove it later when no longer needed to save memory
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(ChatItem.getInstance(), () -> STACKS.remove(p), 100L);
|
||||
}
|
||||
if (obj.size() == 1 && obj.has("text")) {
|
||||
itemTooltip.add("text", obj.get("text"));
|
||||
ChatItem.debug("[JsonManipulator] Parsed quick: " + obj.toString() + ", wrapper: " + itemTooltip);
|
||||
return ChatManager.replaceSeparator(chat, itemTooltip.toString(), replacement);
|
||||
wrapper.add("text", obj.get("text"));
|
||||
ChatItem.debug("[JsonManipulator] Parsed quick: " + obj.toString() + ", wrapper: " + wrapper);
|
||||
return ChatManager.replaceSeparator(chat, wrapper.toString(), replacement);
|
||||
}
|
||||
obj.add("extra", parseArray(obj.has("extra") ? obj.getAsJsonArray("extra") : new JsonArray(), itemTooltip));
|
||||
obj.add("extra", parseArray(obj.has("extra") ? obj.getAsJsonArray("extra") : new JsonArray(), wrapper));
|
||||
if (!obj.has("text")) {
|
||||
obj.addProperty("text", "");
|
||||
}
|
||||
ChatItem.debug("Parsed array for item: " + obj.toString() + ", wrapper: " + itemTooltip);
|
||||
ChatItem.debug("Parsed array for item: " + obj.toString() + ", wrapper: " + wrapper);
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
@@ -149,7 +149,10 @@ public class JSONManipulator {
|
||||
replacer.set(i, jar);
|
||||
}
|
||||
} else if (element.isJsonPrimitive() && isComplex) {
|
||||
ChatItem.debug("[JSONManipulator] Put " + element + " to trash as it's primitive with complex things");
|
||||
if(ChatManager.containsSeparator(element.getAsString())) {
|
||||
addParsedStringToArray(element.getAsString(), replacer, element, tooltip);
|
||||
} else
|
||||
ChatItem.debug("[JSONManipulator] Put " + element + " to trash as it's primitive with complex things");
|
||||
// ignore
|
||||
} else {
|
||||
addParsedStringToArray(element.getAsString(), replacer, element, tooltip);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.dadus33.chatitem.chatmanager.v1.listeners;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -63,10 +63,9 @@ public class ChatPacketManager extends PacketHandler {
|
||||
tryRegister(getter);
|
||||
}
|
||||
try {
|
||||
if (Class.forName("net.kyori.adventure.text.Component") != null)
|
||||
tryRegister(new AdventureComponentManager());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
Class.forName("net.kyori.adventure.text.Component");
|
||||
tryRegister(new AdventureComponentManager());
|
||||
} catch (Exception e) {}
|
||||
ChatItem.getInstance().getLogger().info("Loaded " + componentManager.size() + " getter for base components.");
|
||||
ChatItem.debug("ComponentManager: " + String.join(", ", componentManager.stream().map(IComponentManager::getClass).map(Class::getSimpleName).collect(Collectors.toList())));
|
||||
}
|
||||
@@ -74,6 +73,8 @@ public class ChatPacketManager extends PacketHandler {
|
||||
private void tryRegister(IComponentManager getter) {
|
||||
if (getter.hasConditions())
|
||||
componentManager.add(getter);
|
||||
else
|
||||
ChatItem.debug("Component " + getter.getClass().getSimpleName() + " doesn't answer conditions");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,14 +118,7 @@ public class ChatPacketManager extends PacketHandler {
|
||||
if (json == null || choosedGetter == null) {
|
||||
ChatItem.debug("Can't find valid json getter or json itself");
|
||||
ChatItem.debug("String: " + packet.getStrings().getContent());
|
||||
for (Field f : e.getPacket().getClass().getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
try {
|
||||
ChatItem.debug(f.getName() + ": " + f.get(e.getPacket()));
|
||||
} catch (Exception exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
}
|
||||
PacketUtils.printPacketToDebug(e.getPacket());
|
||||
return; // can't find something
|
||||
}
|
||||
if (!ChatManager.containsSeparator(json)) // if the message doesn't contain the BELL separator
|
||||
@@ -140,12 +134,14 @@ public class ChatPacketManager extends PacketHandler {
|
||||
if (getStorage().cooldown > 0 && !itemPlayer.hasPermission("chatitem.ignore-cooldown"))
|
||||
ChatManager.applyCooldown(itemPlayer);
|
||||
IComponentManager getter = choosedGetter;
|
||||
String fjson = json;
|
||||
ChatItem.debug("Final json used: " + fjson);
|
||||
e.setCancelled(true); // We cancel the packet as we're going to resends it anyways
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChatItem.getInstance(), () -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Player p = e.getPlayer();
|
||||
String message = null;
|
||||
try {
|
||||
ItemStack item = ChatManager.getUsableItem(itemPlayer);
|
||||
ItemStack item = ChatManager.getUsableItem(itemPlayer, chat.getSlot());
|
||||
if (!ItemUtils.isEmpty(item)) {
|
||||
ItemStack copy = item.clone();
|
||||
|
||||
@@ -185,10 +181,10 @@ public class ChatPacketManager extends PacketHandler {
|
||||
copy.setItemMeta(bsm);
|
||||
}
|
||||
}
|
||||
lastSentPacket = getter.manageItem(p, chat, e, item, getStorage());
|
||||
lastSentPacket = getter.manageItem(p, chat, e, item, fjson, getStorage());
|
||||
} else {
|
||||
if (!getStorage().handDisabled) {
|
||||
lastSentPacket = getter.manageEmpty(p, chat, e, getStorage());
|
||||
lastSentPacket = getter.manageEmpty(p, chat, e, fjson, getStorage());
|
||||
}
|
||||
}
|
||||
if (lastSentPacket == null)
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package me.dadus33.chatitem.chatmanager.v1.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.playerversion.hooks.DefaultVersionHook;
|
||||
import me.dadus33.chatitem.utils.Version;
|
||||
|
||||
public class HandshakeListener extends PacketAdapter {
|
||||
|
||||
public HandshakeListener(ChatItem pl) {
|
||||
super(pl, ListenerPriority.MONITOR, PacketType.Handshake.Client.SET_PROTOCOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(final PacketEvent e){
|
||||
if(e.isPlayerTemporary() || e.getPlayer() == null)
|
||||
return;
|
||||
PacketType.Protocol p = e.getPacket().getProtocols().read(0);
|
||||
if(p == PacketType.Protocol.STATUS || p == PacketType.Protocol.LEGACY){
|
||||
return;
|
||||
}
|
||||
final int version = e.getPacket().getIntegers().readSafely(0);
|
||||
//Delay the mapping to make sure the true address of the player was received when using bungeecord or other types of proxies
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () ->
|
||||
DefaultVersionHook.PROTOCOL_PER_ADDRESS.put(Version.stringifyAdress(e.getPlayer().getAddress()), version), 10L);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package me.dadus33.chatitem.chatmanager.v1.packets.custom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -39,11 +39,11 @@ public class CustomPacketManager extends PacketManager implements Listener {
|
||||
pl.getServer().getPluginManager().registerEvents(this, pl);
|
||||
|
||||
// we wait the start server
|
||||
Bukkit.getScheduler().runTaskLater(pl, () -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
isStarted = true;
|
||||
for(Player p : Utils.getOnlinePlayers())
|
||||
addPlayer(p);
|
||||
}, 20);
|
||||
});
|
||||
}
|
||||
|
||||
public Plugin getPlugin() {
|
||||
|
||||
+2
-2
@@ -87,8 +87,8 @@ public class INC2Channel extends ChannelAbstract {
|
||||
@Override
|
||||
public Channel getChannel(Player p) throws Exception {
|
||||
Object playerConnection = getPlayerConnection(p);
|
||||
Object networkManager = ReflectionUtils.getFirstWith(playerConnection, playerConnection.getClass(), PacketUtils.getNmsClass("NetworkManager", "network."));
|
||||
return ReflectionUtils.getFirstWith(networkManager, networkManager.getClass(), Channel.class);
|
||||
Object networkManager = ReflectionUtils.getFirstWith(playerConnection, PacketUtils.getNmsClass("NetworkManager", "network."));
|
||||
return ReflectionUtils.getFirstWith(networkManager, Channel.class);
|
||||
}
|
||||
|
||||
private class ChannelHandlerSent extends ChannelOutboundHandlerAdapter {
|
||||
|
||||
-2
@@ -13,7 +13,6 @@ import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.chatmanager.v1.listeners.HandshakeListener;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.ChatItemPacket;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.PacketManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.packets.PacketType;
|
||||
@@ -46,7 +45,6 @@ public class ProtocollibPacketManager extends PacketManager {
|
||||
e.setCancelled(packet.isCancelled());
|
||||
}
|
||||
});
|
||||
protocolManager.addPacketListener(new HandshakeListener(pl));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -20,13 +18,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.ItemPlayer;
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.Chat;
|
||||
import me.dadus33.chatitem.chatmanager.ChatAction;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.hook.DiscordSrvSupport;
|
||||
import me.dadus33.chatitem.playernamer.PlayerNamerManager;
|
||||
import me.dadus33.chatitem.utils.ColorManager;
|
||||
import me.dadus33.chatitem.utils.ItemUtils;
|
||||
import me.dadus33.chatitem.utils.Messages;
|
||||
import me.dadus33.chatitem.utils.PacketUtils;
|
||||
import me.dadus33.chatitem.utils.ReflectionUtils;
|
||||
import me.dadus33.chatitem.utils.Utils;
|
||||
@@ -86,10 +87,12 @@ public class ChatListener implements Listener {
|
||||
if (e.isCancelled()) {
|
||||
if (ChatItem.getInstance().getChatManager().size() == 1) { // only chat
|
||||
String msg = e.getMessage().toLowerCase();
|
||||
for (String rep : c.placeholders) {
|
||||
if (msg.contains(rep)) {
|
||||
ChatItem.debug("You choose 'chat' manager but it seems to don't be the good choice. More informations here: https://github.com/dadus33-plugins/ChatItem/wiki");
|
||||
return;
|
||||
for(ItemSlot slot : ItemSlot.values()) {
|
||||
for (String rep : slot.getPlaceholders()) {
|
||||
if (msg.contains(rep)) {
|
||||
ChatItem.debug("You choose 'chat' manager but it seems to don't be the good choice. More informations here: https://github.com/dadus33-plugins/ChatItem/wiki");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,52 +103,43 @@ public class ChatListener implements Listener {
|
||||
if(ChatManager.containsSeparator(e.getMessage())) { // fix for v1
|
||||
Chat chat = Chat.getFrom(e.getMessage());
|
||||
if(chat != null)
|
||||
e.setMessage(ChatManager.replaceSeparator(chat, e.getMessage(), c.placeholders.get(0)));
|
||||
e.setMessage(ChatManager.replaceSeparator(chat, e.getMessage(), chat.getSlot().getPlaceholders().get(0)));
|
||||
}
|
||||
String placeholder = null;
|
||||
for (String rep : c.placeholders) {
|
||||
if (e.getMessage().contains(rep)) {
|
||||
placeholder = rep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (placeholder == null) { // if not found
|
||||
ItemSlot slot = ItemSlot.getItemSlotFromMessage(e.getMessage());
|
||||
if (slot == null) { // if not found
|
||||
ChatItem.debug("(v2) Can't found placeholder in: " + e.getMessage() + " > " + PlayerNamerManager.getPlayerNamer().getName(p));
|
||||
return;
|
||||
}
|
||||
ItemStack item = ChatManager.getUsableItem(p);
|
||||
if (!ChatManager.canShowItem(p, item, e))
|
||||
ChatAction action = ChatManager.getChatAction(slot, p);
|
||||
if(action.isItem() && !ChatManager.canShowItem(p, action.getItem(), slot, e))
|
||||
return;
|
||||
e.setCancelled(true);
|
||||
String format = e.getFormat();
|
||||
String msg, defMsg = e.getMessage();
|
||||
for (String rep : c.placeholders) {
|
||||
defMsg = defMsg.replace(rep, Character.toString(ChatManager.SEPARATOR));
|
||||
}
|
||||
String defMsg = slot.replacePlaceholdersToSeparator(e.getMessage());
|
||||
if (Utils.countMatches(defMsg, Character.toString(ChatManager.SEPARATOR)) > getStorage().limit) {
|
||||
if (!getStorage().messageLimit.isEmpty())
|
||||
p.sendMessage(getStorage().messageLimit);
|
||||
return;
|
||||
}
|
||||
String msg;
|
||||
if (format.contains("%1$s") || format.contains("%2$s")) {
|
||||
msg = (format.contains("%2$s") ? String.format(format, p.getDisplayName(), defMsg) : String.format(format, p.getDisplayName()));
|
||||
} else {
|
||||
msg = format.replace(e.getMessage(), defMsg);
|
||||
}
|
||||
String itemName = ChatManager.getNameOfItem(p, item, c);
|
||||
String itemName = ChatManager.getNameForChatAction(p, action, c);
|
||||
String loggedMessage = msg.replace(ChatManager.SEPARATOR + "", itemName).replace("{name}", p.getName()).replace("{display-name}", p.getDisplayName());
|
||||
Bukkit.getConsoleSender().sendMessage(loggedMessage); // show in log
|
||||
if (ChatItem.discordSrvSupport)
|
||||
DiscordSrvSupport.sendChatMessage(p, defMsg.replace(ChatManager.SEPARATOR + "", itemName).replace("{name}", p.getName()).replace("{display-name}", p.getDisplayName()));
|
||||
DiscordSrvSupport.sendChatMessage(p, defMsg.replace(ChatManager.SEPARATOR + "", itemName).replace("{name}", p.getName()).replace("{display-name}", p.getDisplayName()), e);
|
||||
Set<Player> recipients = e.getRecipients().isEmpty() ? new HashSet<>(Bukkit.getOnlinePlayers()) : e.getRecipients();
|
||||
ChatItem.debug("Msg: " + msg.replace(ChatColor.COLOR_CHAR, '&') + ", format: " + format + " to " + recipients.size() + " players");
|
||||
recipients.forEach((pl) -> showItem(pl, p, item, msg));
|
||||
recipients.forEach((pl) -> showItem(pl, p, action, msg));
|
||||
if (c.cooldown > 0 && !p.hasPermission("chatitem.ignore-cooldown"))
|
||||
ChatManager.applyCooldown(p);
|
||||
}
|
||||
|
||||
public static void showItem(Player to, Player origin, ItemStack item, String msg) {
|
||||
public static void showItem(Player to, Player origin, ChatAction action, String msg) {
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
ChatColor color = ChatColor.WHITE;
|
||||
String colorCode = "", text = "";
|
||||
@@ -158,7 +152,7 @@ public class ChatListener implements Listener {
|
||||
&& color != null && color != ChatColor.WHITE) {
|
||||
text = text.substring(2); // remove some code which should not be here
|
||||
}
|
||||
appendToComponentBuilder(builder, createComponent(text, color));
|
||||
appendToComponentBuilder(builder, createComponent(to, text, color, action));
|
||||
text = "";
|
||||
}
|
||||
waiting = true; // waiting for color code
|
||||
@@ -194,8 +188,11 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
if (args == ChatManager.SEPARATOR) {
|
||||
// here put the item
|
||||
appendToComponentBuilder(builder, fixColorComponent(text, color));
|
||||
addItem(builder, to, origin, item);
|
||||
appendToComponentBuilder(builder, fixColorComponent(to, text, color, action));
|
||||
if(action.isItem())
|
||||
addItem(builder, to, origin, action.getItem(), action);
|
||||
else
|
||||
addCommand(builder, to, origin, action.getCommand(), action);
|
||||
text = "";
|
||||
if(ChatManager.containsSeparatorEnd(msg))
|
||||
removing = true;
|
||||
@@ -208,15 +205,15 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (!text.isEmpty())
|
||||
appendToComponentBuilder(builder, createComponent(text, color));
|
||||
appendToComponentBuilder(builder, createComponent(to, text, color, action));
|
||||
to.spigot().sendMessage(builder.create());
|
||||
}
|
||||
|
||||
public static void addItem(ComponentBuilder builder, Player to, Player origin, ItemStack item) {
|
||||
public static void addItem(ComponentBuilder builder, Player to, Player origin, ItemStack item, ChatAction action) {
|
||||
Storage c = ChatItem.getInstance().getStorage();
|
||||
if (!ItemUtils.isEmpty(item)) {
|
||||
ComponentBuilder itemComponent = new ComponentBuilder("");
|
||||
appendToComponentBuilder(itemComponent, fixColorComponent(ChatManager.getNameOfItem(to, item, c), ChatColor.WHITE, item));
|
||||
appendToComponentBuilder(itemComponent, fixColorComponent(to, ChatManager.getNameOfItem(to, item, c), ChatColor.WHITE, action));
|
||||
ChatItem.debug("Item for " + to.getName() + " (ver: " + ItemPlayer.getPlayer(to).getVersion().name() + ") : " + PacketUtils.getNbtTag(item));
|
||||
// itemComponent.event(new HoverEvent(Action.SHOW_ITEM, itemBaseComponent));
|
||||
appendToComponentBuilder(builder, itemComponent.create());
|
||||
@@ -245,6 +242,12 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCommand(ComponentBuilder builder, Player to, Player origin, String command, ChatAction action) {
|
||||
ComponentBuilder itemComponent = new ComponentBuilder("");
|
||||
appendToComponentBuilder(itemComponent, fixColorComponent(to, Messages.getMessage(action.getSlot().name().toLowerCase() + ".chat", "%cible%", origin.getName()), ChatColor.WHITE, action));
|
||||
appendToComponentBuilder(builder, itemComponent.create());
|
||||
}
|
||||
|
||||
public static void appendToComponentBuilder(ComponentBuilder builder, BaseComponent[] comps) {
|
||||
if (shouldUseAppendMethod) {
|
||||
try {
|
||||
@@ -266,11 +269,7 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseComponent[] fixColorComponent(String message, ChatColor color) {
|
||||
return fixColorComponent(message, color, null);
|
||||
}
|
||||
|
||||
public static BaseComponent[] fixColorComponent(String message, ChatColor color, @Nullable ItemStack item) {
|
||||
public static BaseComponent[] fixColorComponent(Player to, String message, ChatColor color, ChatAction action) {
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
String colorCode = "", text = "";
|
||||
boolean waiting = false;
|
||||
@@ -278,7 +277,7 @@ public class ChatListener implements Listener {
|
||||
if (args == '§') { // begin of color
|
||||
if (colorCode.isEmpty() && !text.isEmpty()) { // text before this char
|
||||
ChatItem.debug("Append while fixing name " + (ColorManager.isHexColor(color) && builder.getParts().isEmpty() ? ColorManager.removeColorAtBegin(text) : text));
|
||||
appendToComponentBuilder(builder, createComponent(ColorManager.isHexColor(color) ? ColorManager.removeColorAtBegin(text) : text, color, item));
|
||||
appendToComponentBuilder(builder, createComponent(to, ColorManager.isHexColor(color) ? ColorManager.removeColorAtBegin(text) : text, color, action));
|
||||
text = "";
|
||||
}
|
||||
waiting = true; // waiting for color code
|
||||
@@ -317,21 +316,21 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (!text.isEmpty()) {
|
||||
appendToComponentBuilder(builder, createComponent(text, color, item));
|
||||
appendToComponentBuilder(builder, createComponent(to, text, color, action));
|
||||
}
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private static BaseComponent[] createComponent(String text, ChatColor color) {
|
||||
return createComponent(text, color, null);
|
||||
}
|
||||
|
||||
private static BaseComponent[] createComponent(String text, ChatColor color, ItemStack item) {
|
||||
private static BaseComponent[] createComponent(Player to, String text, ChatColor color, ChatAction action) {
|
||||
ComponentBuilder littleBuilder = new ComponentBuilder(text);
|
||||
if(color != null && color != ChatColor.RESET) // don't add reset thing
|
||||
littleBuilder.color(color);
|
||||
if (item != null) // add to all possible sub parts
|
||||
littleBuilder.event(Utils.createItemHover(item));
|
||||
if (action.isItem())
|
||||
littleBuilder.event(Utils.createItemHover(action.getItem(), to));
|
||||
else {
|
||||
littleBuilder.event(Utils.createTextHover(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover")));
|
||||
littleBuilder.event(Utils.createRunCommand(action.getCommand()));
|
||||
}
|
||||
return littleBuilder.create();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -16,7 +17,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.InventoryShower;
|
||||
import me.dadus33.chatitem.ItemSlot;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.chatmanager.ChatAction;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v2.ChatListener;
|
||||
import me.dadus33.chatitem.listeners.InventoryListener;
|
||||
@@ -42,25 +46,25 @@ public class ChatItemCommand implements CommandExecutor, TabExecutor {
|
||||
InventoryListener.open(p);
|
||||
} else if (args[0].equalsIgnoreCase("reload") && p.hasPermission("chatitem.reload")) {
|
||||
ChatItem.reload(sender);
|
||||
} else if (args[0].equalsIgnoreCase("show")) {
|
||||
} else if (args[0].equalsIgnoreCase("show") && ChatItem.getInstance().getStorage().cmdShow) {
|
||||
Player cible = args.length == 1 ? p : Bukkit.getPlayer(args[1]);
|
||||
if(cible == null) {
|
||||
Messages.sendMessage(p, "player-not-found", "%arg%", args[1]);
|
||||
return false;
|
||||
}
|
||||
Storage c = ChatItem.getInstance().getStorage();
|
||||
ItemStack item = ChatManager.getUsableItem(cible);
|
||||
ChatListener.showItem(p, cible, item, c.commandFormat.replace("%name%", cible.getName()).replace("%item%", ChatManager.SEPARATOR + ""));
|
||||
} else if (args[0].equalsIgnoreCase("broadcast")) {
|
||||
ItemStack item = ChatManager.getUsableItem(cible, ItemSlot.HAND);
|
||||
ChatListener.showItem(p, cible, new ChatAction(ItemSlot.HAND, item), c.commandFormat.replace("%name%", cible.getName()).replace("%item%", ChatManager.SEPARATOR + ""));
|
||||
} else if (args[0].equalsIgnoreCase("broadcast") && ChatItem.getInstance().getStorage().cmdBroadcast) {
|
||||
Player cible = args.length == 1 ? p : Bukkit.getPlayer(args[1]);
|
||||
if(cible == null) {
|
||||
Messages.sendMessage(p, "player-not-found", "%arg%", args[1]);
|
||||
return false;
|
||||
}
|
||||
Storage c = ChatItem.getInstance().getStorage();
|
||||
ItemStack item = ChatManager.getUsableItem(cible);
|
||||
ItemStack item = ChatManager.getUsableItem(cible, ItemSlot.HAND);
|
||||
for(Player all : Bukkit.getOnlinePlayers())
|
||||
ChatListener.showItem(all, cible, item, c.commandFormat.replace("%name%", cible.getName()).replace("%item%", ChatManager.SEPARATOR + ""));
|
||||
ChatListener.showItem(all, cible, new ChatAction(ItemSlot.HAND, item), c.commandFormat.replace("%name%", cible.getName()).replace("%item%", ChatManager.SEPARATOR + ""));
|
||||
} else if (args[0].equalsIgnoreCase("link") || args[0].equalsIgnoreCase("links")) {
|
||||
ConfigurationSection config = ChatItem.getInstance().getConfig()
|
||||
.getConfigurationSection("messages.chatitem-cmd.links");
|
||||
@@ -77,7 +81,7 @@ public class ChatItemCommand implements CommandExecutor, TabExecutor {
|
||||
text.addExtra(linkComp);
|
||||
}
|
||||
p.spigot().sendMessage(text);
|
||||
} else if (args[0].equalsIgnoreCase("select")) {
|
||||
} else if (args[0].equalsIgnoreCase("select") && p.hasPermission("chatitem.reload")) {
|
||||
if(args.length == 1) {
|
||||
p.sendMessage(ChatColor.GRAY + "----------" + ChatColor.GOLD + " ChatItem - Setup " + ChatColor.GRAY + "----------");
|
||||
p.sendMessage(ChatColor.AQUA + "Welcome in the help of setup." + ChatColor.YELLOW + " Please follow step by simply answer to test.");
|
||||
@@ -110,7 +114,19 @@ public class ChatItemCommand implements CommandExecutor, TabExecutor {
|
||||
p.sendMessage(ChatColor.RED + "Can't find if it works");
|
||||
}
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("seeinv")) {
|
||||
if(args.length == 3 && Utils.isUUID(args[2])) {
|
||||
Player cible = Bukkit.getPlayer(UUID.fromString(args[2]));
|
||||
if(cible == null || !cible.isOnline()) {
|
||||
Messages.sendMessage(p, "player-not-found", "%arg%", args[2]);
|
||||
return false;
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("inventory")) {
|
||||
InventoryShower.showInventory(p, cible);
|
||||
} else if(args[1].equalsIgnoreCase("enderchest")) {
|
||||
InventoryShower.showEnderchest(p, cible);
|
||||
}
|
||||
} // else just ignore
|
||||
} else {
|
||||
Messages.sendMessage(p, "chatitem-cmd.help");
|
||||
}
|
||||
@@ -141,7 +157,16 @@ public class ChatItemCommand implements CommandExecutor, TabExecutor {
|
||||
List<String> list = new ArrayList<>();
|
||||
String prefix = arg[arg.length - 1].toLowerCase(Locale.ROOT);
|
||||
if(arg.length <= 2) {
|
||||
for (String s : Arrays.asList("help", "admin", "reload", "link", "show", "broadcast", "select"))
|
||||
if(sender.hasPermission("chatitem.reload")) {
|
||||
for (String s : Arrays.asList("admin", "reload", "select"))
|
||||
if (prefix.isEmpty() || s.startsWith(prefix))
|
||||
list.add(s);
|
||||
}
|
||||
if (ChatItem.getInstance().getStorage().cmdShow && (prefix.isEmpty() || "show".startsWith(prefix)))
|
||||
list.add("show");
|
||||
if (ChatItem.getInstance().getStorage().cmdBroadcast && (prefix.isEmpty() || "broadcast".startsWith(prefix)))
|
||||
list.add("broadcast");
|
||||
for (String s : Arrays.asList("help", "link"))
|
||||
if (prefix.isEmpty() || s.startsWith(prefix))
|
||||
list.add(s);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package me.dadus33.chatitem.hook;
|
||||
|
||||
import org.mineacademy.chatcontrol.settings.Settings;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
|
||||
public class ChatControlSupport {
|
||||
|
||||
public static void init(ChatItem pl) {
|
||||
Settings.Chat.Grammar.CAPITALIZE = false;
|
||||
Settings.Chat.Grammar.INSERT_DOT = false;
|
||||
try {
|
||||
Class<?> clz = Class.forName("org.mineacademy.chatcontrol.settings.Settings$Chat$Grammar");
|
||||
clz.getField("CAPITALIZE").setBoolean(null, false);
|
||||
clz.getField("INSERT_DOT").setBoolean(null, false);
|
||||
pl.getLogger().info("Loaded ChatControl support by disabling 2 options in 'Chat.Grammar' config.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
pl.getLogger().info("Loaded ChatControl support by disabling 2 options in 'Chat.Grammar' config.");
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,31 @@
|
||||
package me.dadus33.chatitem.hook;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class DiscordSrvSupport {
|
||||
|
||||
public static boolean isSendingMessage() {
|
||||
return ChatItem.getInstance().getStorage().discordSrvSendMsg;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void sendChatMessage(Player p, String message) {
|
||||
public static void sendChatMessage(Player p, String message, Event e) {
|
||||
DiscordSRV pl = DiscordSRV.getPlugin();
|
||||
if (DiscordSRV.config().getBooleanElse("UseModernPaperChatEvent", false) && pl.isModernChatEventAvailable()) {
|
||||
return;
|
||||
}
|
||||
pl.processChatMessage(p, message, pl.getOptionalChannel("global"), false);
|
||||
pl.processChatMessage(p, message, pl.getOptionalChannel("global"), false, e);
|
||||
}
|
||||
|
||||
public static void sendChatMessage(Player p, Component message, Event e) {
|
||||
DiscordSRV pl = DiscordSRV.getPlugin();
|
||||
if (DiscordSRV.config().getBooleanElse("UseModernPaperChatEvent", false) && pl.isModernChatEventAvailable()) {
|
||||
return;
|
||||
}
|
||||
pl.processChatMessage(p, message, pl.getOptionalChannel("global"), false, e);
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,12 @@ public class EcoEnchantsSupport {
|
||||
supportedVersion = 8;
|
||||
else if(ver.startsWith("10."))
|
||||
supportedVersion = 10;
|
||||
else if(ver.startsWith("11."))
|
||||
supportedVersion = 11;
|
||||
else if(ver.startsWith("12."))
|
||||
supportedVersion = 12;
|
||||
else {
|
||||
ChatItem.getInstance().getLogger().info("Failed to find support version for EcoEnchants " + ver);
|
||||
ChatItem.getInstance().getLogger().warning("Failed to find support version for EcoEnchants " + ver);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -44,7 +48,7 @@ public class EcoEnchantsSupport {
|
||||
ChatItem.debug("Added " + addLore.size() + " lores from EcoEnchants");
|
||||
} else
|
||||
ChatItem.debug("No lore to add from EcoEnchants");
|
||||
} else if(supportedVersion == 10) {
|
||||
} else if(supportedVersion >= 10) {
|
||||
EcoEnchantsV10Support.display(item);
|
||||
}
|
||||
return item;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.dadus33.chatitem.hook.ecoenchants;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class EcoEnchantsV10Support {
|
||||
public static EnchantDisplay getEnchantDisplay() {
|
||||
if (enchantDisplay == null) {
|
||||
try {
|
||||
enchantDisplay = EnchantDisplay.class.getConstructor(EcoEnchantsPlugin.class).newInstance(EcoEnchantsPlugin.getInstance());
|
||||
enchantDisplay = EnchantDisplay.class.getConstructor(EcoEnchantsPlugin.class).newInstance(Bukkit.getPluginManager().getPlugin("EcoEnchants"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface INamer {
|
||||
*/
|
||||
String getName(Player p, ItemStack item, Storage storage);
|
||||
|
||||
enum Priority {
|
||||
public enum Priority {
|
||||
MAJOR(4),
|
||||
IMPORTANT(3),
|
||||
MEDIUM(2),
|
||||
|
||||
@@ -12,12 +12,14 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.Storage;
|
||||
import me.dadus33.chatitem.Translation;
|
||||
import me.dadus33.chatitem.listeners.holder.AdminHolder;
|
||||
import me.dadus33.chatitem.listeners.holder.CustomInventoryHolder;
|
||||
import me.dadus33.chatitem.utils.ItemUtils;
|
||||
import me.dadus33.chatitem.utils.Messages;
|
||||
|
||||
@@ -25,8 +27,16 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
if(e.getClickedInventory() == null || !(e.getWhoClicked() instanceof Player) || e.getCurrentItem() == null
|
||||
|| !(e.getClickedInventory().getHolder() instanceof AdminHolder))
|
||||
if(e.getClickedInventory() == null || !(e.getWhoClicked() instanceof Player) || e.getCurrentItem() == null)
|
||||
return;
|
||||
InventoryHolder holder = e.getClickedInventory().getHolder();
|
||||
if(holder == null)
|
||||
return;
|
||||
if(holder instanceof CustomInventoryHolder) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!(holder instanceof AdminHolder))
|
||||
return;
|
||||
e.setCancelled(true);
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
@@ -38,8 +48,7 @@ public class InventoryListener implements Listener {
|
||||
} else if(type.equals(Material.BOOK)) {
|
||||
TranslationInventoryListener.open(p, 0);
|
||||
} else if(type.equals(Material.PAPER)) {
|
||||
AdminHolder holder = (AdminHolder) e.getClickedInventory().getHolder();
|
||||
String key = holder.keyBySlot.get(e.getSlot());
|
||||
String key = ((AdminHolder) holder).keyBySlot.get(e.getSlot());
|
||||
if(key != null) {
|
||||
setInConfig("manager", key);
|
||||
p.closeInventory();
|
||||
@@ -48,9 +57,6 @@ public class InventoryListener implements Listener {
|
||||
} else if(type.equals(ItemUtils.INK_SAC)) {
|
||||
setInConfig("general.color-if-already-colored", c.colorIfColored = !c.colorIfColored);
|
||||
open(p);
|
||||
} else if(type.equals(Material.REDSTONE)) {
|
||||
setInConfig("general.deny-if-no-item", c.denyIfNoItem = !c.denyIfNoItem);
|
||||
open(p);
|
||||
} else if(type.equals(Material.STICK)) {
|
||||
setInConfig("general.hand.disabled", c.handDisabled = !c.handDisabled);
|
||||
open(p);
|
||||
@@ -100,7 +106,6 @@ public class InventoryListener implements Listener {
|
||||
inv.setItem(8, getBoolChangeItem(ItemUtils.FIREWORK_CHARGE, "debug", c.debug));
|
||||
|
||||
inv.setItem(18, getBoolChangeItem(ItemUtils.INK_SAC, "color-if-already-colored", c.colorIfColored));
|
||||
inv.setItem(19, getBoolChangeItem(Material.REDSTONE, "deny-no-item", c.denyIfNoItem));
|
||||
inv.setItem(20, getBoolChangeItem(Material.STICK, "hand-disabled", c.handDisabled));
|
||||
inv.setItem(21, getAmountChangeItem(Material.IRON_DOOR, "limit-per-message", c.limit));
|
||||
inv.setItem(22, getAmountChangeItem(Material.APPLE, "cooldown", c.cooldown));
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.dadus33.chatitem.listeners.holder;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class CustomInventoryHolder implements InventoryHolder {
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package me.dadus33.chatitem.playerversion.hooks;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.dadus33.chatitem.playerversion.IPlayerVersion;
|
||||
@@ -9,10 +7,8 @@ import me.dadus33.chatitem.utils.Version;
|
||||
|
||||
public class DefaultVersionHook implements IPlayerVersion {
|
||||
|
||||
public static final HashMap<String, Integer> PROTOCOL_PER_ADDRESS = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion(Player p) {
|
||||
return PROTOCOL_PER_ADDRESS.getOrDefault(Version.stringifyAdress(p.getAddress()), Version.getVersion().MAX_VER);
|
||||
return Version.getVersion().MAX_VER;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.dadus33.chatitem.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -9,18 +10,18 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.chatmanager.v1.json.JSONManipulator;
|
||||
|
||||
public class PacketUtils {
|
||||
|
||||
public static final String VERSION = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",")
|
||||
.split(",")[3];
|
||||
public static final String VERSION = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
public static final String NMS_PREFIX;
|
||||
public static final String OBC_PREFIX;
|
||||
public static final boolean IS_THERMOS;
|
||||
public static final Class<?> CHAT_SERIALIZER, COMPONENT_CLASS;
|
||||
public static final Method ICB_FROM_JSON;
|
||||
|
||||
|
||||
/**
|
||||
* This Map is to reduce Reflection action which take more resources than just
|
||||
* RAM action
|
||||
@@ -29,8 +30,7 @@ public class PacketUtils {
|
||||
|
||||
static {
|
||||
IS_THERMOS = isClassExist("thermos.Thermos");
|
||||
NMS_PREFIX = Version.getVersion().isNewerOrEquals(Version.V1_17) || IS_THERMOS ? "net.minecraft."
|
||||
: "net.minecraft.server." + VERSION + ".";
|
||||
NMS_PREFIX = Version.getVersion().isNewerOrEquals(Version.V1_17) || IS_THERMOS ? "net.minecraft." : "net.minecraft.server." + VERSION + ".";
|
||||
OBC_PREFIX = "org.bukkit.craftbukkit." + VERSION + ".";
|
||||
CHAT_SERIALIZER = getNmsClass("IChatBaseComponent$ChatSerializer", "network.chat.", "ChatSerializer");
|
||||
COMPONENT_CLASS = getNmsClass("IChatBaseComponent", "network.chat.");
|
||||
@@ -40,14 +40,12 @@ public class PacketUtils {
|
||||
/**
|
||||
* Get the Class in NMS, with a processing reducer
|
||||
*
|
||||
* @param name of the NMS class (in net.minecraft.server package ONLY, because
|
||||
* it's NMS)
|
||||
* @param name of the NMS class (in net.minecraft.server package ONLY, because it's NMS)
|
||||
* @return clazz the searched class
|
||||
*/
|
||||
public static Class<?> getNmsClass(String name, String packagePrefix, String... alias) {
|
||||
return ALL_CLASS.computeIfAbsent(name, (a) -> {
|
||||
String fullPrefix = NMS_PREFIX
|
||||
+ (Version.getVersion().isNewerOrEquals(Version.V1_17) || IS_THERMOS ? packagePrefix : "");
|
||||
String fullPrefix = NMS_PREFIX + (Version.getVersion().isNewerOrEquals(Version.V1_17) || IS_THERMOS ? packagePrefix : "");
|
||||
try {
|
||||
Class<?> clazz = Class.forName(fullPrefix + name);
|
||||
if (clazz != null)
|
||||
@@ -169,9 +167,7 @@ public class PacketUtils {
|
||||
public static void sendPacket(Player p, Object packet) {
|
||||
try {
|
||||
Object playerConnection = getPlayerConnection(p);
|
||||
playerConnection.getClass()
|
||||
.getMethod(Version.getVersion().isNewerOrEquals(Version.V1_18) ? "a" : "sendPacket",
|
||||
getNmsClass("Packet", "network.protocol."))
|
||||
playerConnection.getClass().getMethod(Version.getVersion().isNewerOrEquals(Version.V1_18) ? "a" : "sendPacket", getNmsClass("Packet", "network.protocol."))
|
||||
.invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -179,7 +175,7 @@ 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.
|
||||
@@ -189,18 +185,18 @@ public class PacketUtils {
|
||||
*/
|
||||
public static String getNbtTag(ItemStack item) {
|
||||
try {
|
||||
if(getNbtMethod == null) {
|
||||
if (getNbtMethod == null) {
|
||||
Class<?> itemClass = getNmsClass("ItemStack", "world.item.");
|
||||
Version v = Version.getVersion();
|
||||
if(v.isNewerOrEquals(Version.V1_20))
|
||||
if (v.isNewerOrEquals(Version.V1_20))
|
||||
getNbtMethod = itemClass.getDeclaredMethod("w");
|
||||
else if(v.equals(Version.V1_19))
|
||||
else if (v.equals(Version.V1_19))
|
||||
getNbtMethod = itemClass.getDeclaredMethod("u");
|
||||
else if(v.equals(Version.V1_18))
|
||||
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));
|
||||
@@ -210,7 +206,7 @@ public class PacketUtils {
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
|
||||
private static Method getMethod(String name, Class<?> clazz, Class<?>... params) {
|
||||
try {
|
||||
return clazz.getDeclaredMethod(name, params);
|
||||
@@ -219,4 +215,22 @@ public class PacketUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void printPacketToDebug(Object packet) {
|
||||
if(!ChatItem.hasDebug())
|
||||
return;
|
||||
if(packet == null) {
|
||||
ChatItem.debug("Packet is null");
|
||||
return;
|
||||
}
|
||||
ChatItem.debug("Packet with Class: " + packet.getClass().getSimpleName());
|
||||
for (Field f : packet.getClass().getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
try {
|
||||
ChatItem.debug(f.getName() + ": " + f.get(packet));
|
||||
} catch (Exception exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,19 @@ public class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first object which have the searching for class type
|
||||
*
|
||||
* @param from the object where we will try to find the field
|
||||
* @param clazz the class that have to define the field
|
||||
* @param searchingFor the class of the required field
|
||||
* @return the field (or null if not found)
|
||||
* @throws Exception if something gone wrong
|
||||
*/
|
||||
public static <T> T getFirstWith(Object from, Class<T> searchingFor) throws Exception {
|
||||
return getFirstWith(from, from.getClass(), searchingFor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first object which have the searching for class type
|
||||
*
|
||||
@@ -146,6 +159,8 @@ public class ReflectionUtils {
|
||||
return (T) f.get(from);
|
||||
}
|
||||
}
|
||||
if(!clazz.getSuperclass().equals(Object.class))
|
||||
return getFirstWith(from, clazz.getSuperclass(), searchingFor);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -24,8 +26,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dadus33.chatitem.ChatItem;
|
||||
import me.dadus33.chatitem.chatmanager.ChatManager;
|
||||
import me.dadus33.chatitem.chatmanager.v1.json.JSONManipulator;
|
||||
import me.dadus33.chatitem.playerversion.PlayerVersionManager;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.ItemTag;
|
||||
@@ -34,8 +39,9 @@ import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private final static TreeMap<Integer, String> ROMAN_KEYS = new TreeMap<>();
|
||||
private final static HashMap<String, String> ENCHANTS_NAMES = new HashMap<>();
|
||||
private static final Pattern UUID_PATTERN = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$");
|
||||
private static final TreeMap<Integer, String> ROMAN_KEYS = new TreeMap<>();
|
||||
private static final HashMap<String, String> ENCHANTS_NAMES = new HashMap<>();
|
||||
|
||||
static {
|
||||
ROMAN_KEYS.put(1000, "M");
|
||||
@@ -156,8 +162,18 @@ public class Utils {
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isBeforeChatJson(Player p) {
|
||||
return !PlayerVersionManager.getPlayerVersionAdapter().getPlayerVersion(p).isNewerOrEquals(Version.V1_16) && Version.getVersion().isNewerOrEquals(Version.V1_16);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static HoverEvent createItemHover(ItemStack item) {
|
||||
public static HoverEvent createItemHover(ItemStack item, Player to) {
|
||||
if(isBeforeChatJson(to)) {
|
||||
ComponentBuilder comp = new ComponentBuilder("");
|
||||
for(String line : ChatManager.getMaxLinesFromItem(to, item))
|
||||
comp.append(line + "\n");
|
||||
return createTextHover(comp.create());
|
||||
}
|
||||
if(Version.getVersion().isNewerOrEquals(Version.V1_13)) {
|
||||
return new HoverEvent(HoverEvent.Action.SHOW_ITEM, new Item(item.getType().getKey().getKey(), item.getAmount(), ItemTag.ofNbt(PacketUtils.getNbtTag(item))));
|
||||
} else {
|
||||
@@ -178,6 +194,10 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static ClickEvent createRunCommand(String command) {
|
||||
return new ClickEvent(ClickEvent.Action.RUN_COMMAND, command);
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
@@ -213,11 +233,15 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUUID(String s) {
|
||||
return s != null && UUID_PATTERN.matcher(s.toLowerCase()).matches();
|
||||
}
|
||||
|
||||
public static YamlConfiguration copyLoadFile(File folder, String filename, String baseFile) {
|
||||
File legacyConfig = new File(folder, filename);
|
||||
if(!legacyConfig.exists())
|
||||
Utils.copyFile(baseFile, legacyConfig);
|
||||
copyFile(baseFile, legacyConfig);
|
||||
return YamlConfiguration.loadConfiguration(legacyConfig);
|
||||
}
|
||||
|
||||
@@ -228,4 +252,11 @@ public class Utils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String arrayToString(Object[] a) {
|
||||
StringJoiner sj = new StringJoiner(", ");
|
||||
for(Object o : a)
|
||||
sj.add(o == null ? "null" : o.toString());
|
||||
return sj.toString();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,51 @@ general:
|
||||
- "{i}"
|
||||
- "[item]"
|
||||
- "{item}"
|
||||
other-placeholders:
|
||||
# Show what is in the head
|
||||
helmet:
|
||||
# Enable it or not
|
||||
enabled: true
|
||||
# Disallow showing empty item
|
||||
deny-if-no-item: true
|
||||
# Placeholders to use in chat
|
||||
keys:
|
||||
- "[head]"
|
||||
- "{head}"
|
||||
# Show the CHESTPLATE not the enderchest or whatever
|
||||
chestplate:
|
||||
enabled: true
|
||||
deny-if-no-item: true
|
||||
keys:
|
||||
- "[chest]"
|
||||
- "{chest}"
|
||||
# Show leggings
|
||||
leggings:
|
||||
enabled: true
|
||||
deny-if-no-item: true
|
||||
keys:
|
||||
- "[legs]"
|
||||
- "{legs}"
|
||||
# Show what is their feets
|
||||
boots:
|
||||
enabled: false
|
||||
deny-if-no-item: true
|
||||
keys:
|
||||
- "[feet]"
|
||||
- "{feet}"
|
||||
inventory:
|
||||
enabled: true
|
||||
deny-if-no-item: true
|
||||
keys:
|
||||
- "[inv]"
|
||||
- "{inv}"
|
||||
enderchest:
|
||||
enabled: true
|
||||
deny-if-no-item: true
|
||||
keys:
|
||||
- "[ec]"
|
||||
- "{ec}"
|
||||
|
||||
# The format of the item placeholders.
|
||||
name-format: "&b&l&o{name}{amount}&r"
|
||||
# The format of the {amount} placeholder.
|
||||
@@ -93,6 +138,9 @@ general:
|
||||
# Check if the plugin have update
|
||||
check-update: true
|
||||
language: "en_gb"
|
||||
sub-commands:
|
||||
broadcast: true
|
||||
show: true
|
||||
|
||||
|
||||
# Messages section. You can disable any of them by simply leaving them empty, like this: ""
|
||||
@@ -211,3 +259,15 @@ messages:
|
||||
hours: " hours"
|
||||
enabled: "&aEnabled"
|
||||
disabled: "&cDisabled"
|
||||
inventory:
|
||||
name: "%cible%'s inventory"
|
||||
chat: "%cible%'s inventory"
|
||||
hover: "&7Click to see inventory"
|
||||
enderchest:
|
||||
name: "%cible%'s enderchest"
|
||||
chat: "%cible%'s enderchest"
|
||||
hover: "&7Click to see enderchest"
|
||||
|
||||
# If ChatItem send message using DiscordSRV
|
||||
# This option will be ignored if you don't have it
|
||||
discord-srv-send-our: true
|
||||
@@ -5,6 +5,7 @@ version: ${project.version}
|
||||
softdepend: [ViaVersion, ProtocolSupport, ProtocolLib, LangUtils, HexNicks, EcoEnchants, DiscordSRV, ChatControl, ChatManager]
|
||||
authors: [dadus33, WOLFI3654, Elikill58]
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
|
||||
commands:
|
||||
cireload:
|
||||
|
||||
Reference in new issue
Block a user