mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Updated Format API
This commit is contained in:
parent
96edb124f0
commit
3a89d5d6c7
@ -46,30 +46,10 @@ public class VentureChatGui extends MineverseCommand {
|
|||||||
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer((Player) sender);
|
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer((Player) sender);
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.gui")) {
|
if(mcp.getPlayer().hasPermission("venturechat.gui")) {
|
||||||
MineverseChatPlayer target = MineverseChatAPI.getMineverseChatPlayer(args[0]);
|
MineverseChatPlayer target = MineverseChatAPI.getMineverseChatPlayer(args[0]);
|
||||||
if(target == null) {
|
if(target == null && !args[0].equals("Discord")) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString()
|
mcp.getPlayer().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString()
|
||||||
.replace("{args}", args[0]));
|
.replace("{args}", args[0]));
|
||||||
return;
|
return;
|
||||||
/*
|
|
||||||
UUID uuid = null;
|
|
||||||
try {
|
|
||||||
uuid = UUIDFetcher.getUUIDOf(args[0]);
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
String name = args[0];
|
|
||||||
ChatChannel current = MineverseChat.ccInfo.getDefaultChannel();
|
|
||||||
Set<UUID> ignores = new HashSet<UUID>();
|
|
||||||
Set<String> listening = new HashSet<String>();
|
|
||||||
listening.add(current.getName());
|
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
|
||||||
List<String> mail = new ArrayList<String>();
|
|
||||||
String jsonFormat = "Default";
|
|
||||||
target = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, mail, false, null, true, true, name, jsonFormat, false, false, false, true, true, true);
|
|
||||||
MineverseChat.players.add(target);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if(ChatChannel.isChannel(args[1])) {
|
if(ChatChannel.isChannel(args[1])) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(args[1]);
|
ChatChannel channel = ChatChannel.getChannel(args[1]);
|
||||||
@ -81,6 +61,10 @@ public class VentureChatGui extends MineverseCommand {
|
|||||||
sender.sendMessage(LocalizedMessage.INVALID_HASH.toString());
|
sender.sendMessage(LocalizedMessage.INVALID_HASH.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(args[0].equals("Discord")) {
|
||||||
|
this.openInventoryDiscord(mcp, channel, hash);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.openInventory(mcp, target, channel, hash);
|
this.openInventory(mcp, target, channel, hash);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -151,6 +135,62 @@ public class VentureChatGui extends MineverseCommand {
|
|||||||
mcp.getPlayer().openInventory(inv);
|
mcp.getPlayer().openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private void openInventoryDiscord(MineverseChatPlayer mcp, ChatChannel channel, int hash) {
|
||||||
|
Inventory inv = Bukkit.createInventory(null, this.getSlots(), "VentureChat: Discord_Message GUI");
|
||||||
|
ItemStack close = null;
|
||||||
|
ItemStack skull = null;
|
||||||
|
if(VersionHandler.is1_7_10()) {
|
||||||
|
close = new ItemStack(Material.BEDROCK);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
close = new ItemStack(Material.BARRIER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(VersionHandler.is1_7() || VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10() || VersionHandler.is1_11() || VersionHandler.is1_12()) {
|
||||||
|
skull = new ItemStack(Material.getMaterial("SKULL_ITEM"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skull = new ItemStack(Material.PLAYER_HEAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemMeta closeMeta = close.getItemMeta();
|
||||||
|
closeMeta.setDisplayName("§oClose GUI");
|
||||||
|
close.setItemMeta(closeMeta);
|
||||||
|
|
||||||
|
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
||||||
|
skullMeta.setOwner("Scarsz");
|
||||||
|
skullMeta.setDisplayName("§bDiscord_Message");
|
||||||
|
List<String> skullLore = new ArrayList<String>();
|
||||||
|
skullLore.add("§7Channel: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName());
|
||||||
|
skullLore.add("§7Hash: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + hash);
|
||||||
|
skullMeta.setLore(skullLore);
|
||||||
|
skull.setItemMeta(skullMeta);
|
||||||
|
skull.setDurability((short) 3);
|
||||||
|
inv.setItem(0, skull);
|
||||||
|
|
||||||
|
for(GuiSlot g : MineverseChat.gsInfo.getGuiSlots()) {
|
||||||
|
if(!g.hasPermission() || mcp.getPlayer().hasPermission(g.getPermission())) {
|
||||||
|
if(this.checkSlot(g.getSlot())) {
|
||||||
|
MineverseChat.getInstance().getServer().getConsoleSender().sendMessage(Format.FormatStringAll("&cGUI: " + g.getName() + " has invalid slot: " + g.getSlot() + "!"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ItemStack gStack = new ItemStack(g.getIcon());
|
||||||
|
gStack.setDurability((short) g.getDurability());
|
||||||
|
ItemMeta gMeta = gStack.getItemMeta();
|
||||||
|
String displayName = g.getText().replace("{player_name}", "Discord_Message").replace("{channel}", channel.getName()).replace("{hash}", hash + "");
|
||||||
|
gMeta.setDisplayName(Format.FormatStringAll(displayName));
|
||||||
|
List<String> gLore = new ArrayList<String>();
|
||||||
|
gMeta.setLore(gLore);
|
||||||
|
gStack.setItemMeta(gMeta);
|
||||||
|
inv.setItem(g.getSlot(), gStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inv.setItem(8, close);
|
||||||
|
mcp.getPlayer().openInventory(inv);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkSlot(int slot) {
|
private boolean checkSlot(int slot) {
|
||||||
return slot == 0 || slot == 8;
|
return slot == 0 || slot == 8;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,8 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) e.getWhoClicked());
|
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) e.getWhoClicked());
|
||||||
MineverseChatPlayer target = MineverseChatAPI.getMineverseChatPlayer(e.getView().getTitle().replace(" GUI", "").replace("VentureChat: ", ""));
|
String playerName = e.getView().getTitle().replace(" GUI", "").replace("VentureChat: ", "");
|
||||||
|
MineverseChatPlayer target = MineverseChatAPI.getMineverseChatPlayer(playerName);
|
||||||
ItemStack skull = e.getInventory().getItem(0);
|
ItemStack skull = e.getInventory().getItem(0);
|
||||||
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
||||||
ChatChannel channel = ChatChannel.getChannel(ChatColor.stripColor(skullMeta.getLore().get(0)).replace("Channel: ", ""));
|
ChatChannel channel = ChatChannel.getChannel(ChatColor.stripColor(skullMeta.getLore().get(0)).replace("Channel: ", ""));
|
||||||
@ -257,10 +258,16 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
for(GuiSlot g : MineverseChat.gsInfo.getGuiSlots()) {
|
for(GuiSlot g : MineverseChat.gsInfo.getGuiSlots()) {
|
||||||
if(g.getIcon() == item.getType() && g.getDurability() == item.getDurability() && g.getSlot() == e.getSlot()) {
|
if(g.getIcon() == item.getType() && g.getDurability() == item.getDurability() && g.getSlot() == e.getSlot()) {
|
||||||
String command = g.getCommand().replace("{channel}", channel.getName()).replace("{hash}", hash + "").replace("{player_name}", target.getName());
|
String command = g.getCommand().replace("{channel}", channel.getName()).replace("{hash}", hash + "");
|
||||||
|
if(target != null) {
|
||||||
|
command = command.replace("{player_name}", target.getName());
|
||||||
if(target.isOnline()) {
|
if(target.isOnline()) {
|
||||||
command = PlaceholderAPI.setBracketPlaceholders(target.getPlayer(), command);
|
command = PlaceholderAPI.setBracketPlaceholders(target.getPlayer(), command);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
command = command.replace("{player_name}", "Discord_Message");
|
||||||
|
}
|
||||||
mcp.getPlayer().chat(command);
|
mcp.getPlayer().chat(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public class Format {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertLinks(String s) {
|
private static String convertLinks(String s) {
|
||||||
String remaining = s;
|
String remaining = s;
|
||||||
String temp = "";
|
String temp = "";
|
||||||
int indexLink = -1;
|
int indexLink = -1;
|
||||||
@ -170,11 +170,11 @@ public class Format {
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertToJsonColors(String s) {
|
private static String convertToJsonColors(String s) {
|
||||||
return convertToJsonColors(s, "");
|
return convertToJsonColors(s, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertToJsonColors(String s, String extensions) {
|
private static String convertToJsonColors(String s, String extensions) {
|
||||||
String remaining = s;
|
String remaining = s;
|
||||||
String temp = "";
|
String temp = "";
|
||||||
int indexColor = -1;
|
int indexColor = -1;
|
||||||
@ -286,6 +286,15 @@ public class Format {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String convertPlainTextToJson(String s, boolean convertURL) {
|
||||||
|
if(convertURL) {
|
||||||
|
return "[" + Format.convertLinks(s) + "]";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "[" + convertToJsonColors("§f" + s) + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
|
public static String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
|
||||||
if(player.hasPermission("venturechat.gui")) {
|
if(player.hasPermission("venturechat.gui")) {
|
||||||
json = json.substring(0, json.length() - 1);
|
json = json.substring(0, json.length() - 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user