forked from Upstream/CommandPanels
3.20.1.0 #4
This commit is contained in:
parent
3e9c40c160
commit
ed1b30c6f6
@ -52,8 +52,15 @@ public class CommandPanelsEditor implements CommandExecutor {
|
|||||||
|
|
||||||
// Prepend "fileName: {name}" and "filePath: {relativePath}" to the YAML content
|
// Prepend "fileName: {name}" and "filePath: {relativePath}" to the YAML content
|
||||||
String yamlWithFileNameAndPath = "fileName: " + (relativePath.replaceFirst("[.][^.]+$", "")) + "\n" + fileContents;
|
String yamlWithFileNameAndPath = "fileName: " + (relativePath.replaceFirst("[.][^.]+$", "")) + "\n" + fileContents;
|
||||||
|
byte[] contentBytes = yamlWithFileNameAndPath.getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
// Create a clickable text component with the modified YAML content
|
//65535 is maximum value that can be represented by an unsigned 16-bit binary number
|
||||||
|
if (contentBytes.length > 65535) {
|
||||||
|
// If the content is too large, notify the player to use a different method
|
||||||
|
sender.sendMessage(plugin.tag + ChatColor.RED +
|
||||||
|
"Content too long to paste in chat. Please copy and paste the panel file into the editor manually.");
|
||||||
|
} else {
|
||||||
|
// Safe to send
|
||||||
BaseComponent[] components = new ComponentBuilder(plugin.tag +
|
BaseComponent[] components = new ComponentBuilder(plugin.tag +
|
||||||
net.md_5.bungee.api.ChatColor.GREEN + "Click here to copy " +
|
net.md_5.bungee.api.ChatColor.GREEN + "Click here to copy " +
|
||||||
net.md_5.bungee.api.ChatColor.WHITE + panel.getFile().getName() +
|
net.md_5.bungee.api.ChatColor.WHITE + panel.getFile().getName() +
|
||||||
@ -61,9 +68,10 @@ public class CommandPanelsEditor implements CommandExecutor {
|
|||||||
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yamlWithFileNameAndPath))
|
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yamlWithFileNameAndPath))
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
// Send the clickable text to the player
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.spigot().sendMessage(components);
|
player.spigot().sendMessage(components);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user