|
6 | 6 | import com.sekwah.advancedportals.bukkit.listeners.Listeners;
|
7 | 7 | import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
8 | 8 | import com.sekwah.advancedportals.bukkit.portals.Portal;
|
| 9 | +import net.md_5.bungee.api.ChatColor; |
| 10 | +import net.md_5.bungee.api.ChatMessageType; |
| 11 | +import net.md_5.bungee.api.chat.*; |
9 | 12 | import org.bukkit.DyeColor;
|
10 | 13 | import org.bukkit.Location;
|
11 | 14 | import org.bukkit.Material;
|
|
23 | 26 | import org.bukkit.material.Wool;
|
24 | 27 | import org.bukkit.metadata.FixedMetadataValue;
|
25 | 28 |
|
| 29 | +import javax.xml.soap.Text; |
26 | 30 | import java.util.*;
|
27 | 31 | import java.util.stream.Collectors;
|
28 | 32 |
|
@@ -462,21 +466,31 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
|
462 | 466 | player.sendMessage(PluginMessages.customPrefixFail + " You had no portal selected!");
|
463 | 467 | }
|
464 | 468 | case "gui":
|
| 469 | + // /portal gui remove testarg |
465 | 470 | if (args.length > 1) {
|
466 | 471 | if (args[1].toLowerCase().equals("remove") && args.length > 2) {
|
467 | 472 | sender.sendMessage("");
|
468 | 473 | sender.sendMessage(PluginMessages.customPrefixFail
|
469 | 474 | + " Are you sure you would like to remove the portal \u00A7e" + args[2]
|
470 | 475 | + "\u00A7c?");
|
| 476 | + |
| 477 | + TextComponent removeMessage = new TextComponent(); |
| 478 | + TextComponent yes = new TextComponent("[Yes]"); |
| 479 | + yes.setColor(ChatColor.YELLOW); |
| 480 | + yes.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/portal remove " + args[2])); |
| 481 | + yes.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Confirm removing this portal").create())); |
| 482 | + TextComponent no = new TextComponent("[No]"); |
| 483 | + no.setColor(ChatColor.YELLOW); |
| 484 | + no.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/portal edit " + args[2])); |
| 485 | + no.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Cancel removing this portal").create())); |
| 486 | + |
| 487 | + removeMessage.addExtra(" "); |
| 488 | + removeMessage.addExtra(yes); |
| 489 | + removeMessage.addExtra(" "); |
| 490 | + removeMessage.addExtra(no); |
| 491 | + |
471 | 492 | sender.sendMessage("");
|
472 |
| - plugin.compat.sendRawMessage( |
473 |
| - "{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\"," |
474 |
| - + "\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " |
475 |
| - + args[2] + "\"}}, " |
476 |
| - + "{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"}" |
477 |
| - + ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " |
478 |
| - + args[2] + "\"}}]}", |
479 |
| - player); |
| 493 | + sender.spigot().sendMessage(removeMessage); |
480 | 494 | sender.sendMessage("");
|
481 | 495 | }
|
482 | 496 | }
|
@@ -551,11 +565,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
|
551 | 565 | // TODO add the command autocompletes, add, remove and show
|
552 | 566 | if (args[1].toLowerCase().equals("add")) {
|
553 | 567 | if (args.length > 2) {
|
554 |
| - String portalCommand = args[2]; |
| 568 | + StringBuilder portalCommand = new StringBuilder(args[2]); |
555 | 569 | for (int i = 3; i < args.length; i++) {
|
556 |
| - portalCommand += args[i]; |
| 570 | + portalCommand.append(args[i]); |
557 | 571 | }
|
558 |
| - if (Portal.addCommand(portalName, portalCommand)) { |
| 572 | + if (Portal.addCommand(portalName, portalCommand.toString())) { |
559 | 573 | sender.sendMessage(
|
560 | 574 | PluginMessages.customPrefixFail + " Command added to portal!");
|
561 | 575 | } else {
|
@@ -826,15 +840,65 @@ private void portalEditMenu(CommandSender sender, ConfigAccessor portalConfig, S
|
826 | 840 | sender.sendMessage("");
|
827 | 841 |
|
828 | 842 | Player player = (Player) sender;
|
829 |
| - |
830 |
| - plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \"," |
| 843 | + /*TextComponent editMessage = new TextComponent(); |
| 844 | + editMessage.setColor(ChatColor.GREEN);*/ |
| 845 | +/* TextComponent yes = new TextComponent("Functions"); |
| 846 | + yes.setColor(ChatColor.YELLOW); |
| 847 | + yes.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/portal remove " + args[2])); |
| 848 | + yes.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Confirm removing this portal").create())); |
| 849 | + TextComponent no = new TextComponent("[No]"); |
| 850 | + no.setColor(ChatColor.YELLOW); |
| 851 | + no.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/portal edit " + args[2])); |
| 852 | + no.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Cancel removing this portal").create())); |
| 853 | +
|
| 854 | + removeMessage.addExtra(" "); |
| 855 | + removeMessage.addExtra(no); |
| 856 | + removeMessage.addExtra(" "); |
| 857 | + removeMessage.addExtra(yes);*/ |
| 858 | + |
| 859 | + TextComponent removeButton = new TextComponent("Remove"); |
| 860 | + removeButton.setColor(ChatColor.YELLOW); |
| 861 | + removeButton.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, |
| 862 | + new ComponentBuilder("Remove the selected portal").create())); |
| 863 | + removeButton.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, |
| 864 | + "/portal gui remove " + portalName)); |
| 865 | + |
| 866 | + TextComponent showButton = new TextComponent("Show"); |
| 867 | + showButton.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, |
| 868 | + new ComponentBuilder("Show the selected portal").create())); |
| 869 | + showButton.setColor(ChatColor.YELLOW); |
| 870 | + showButton.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/portal show " + portalName)); |
| 871 | + |
| 872 | + TextComponent renameButton = new TextComponent("Rename"); |
| 873 | + renameButton.setColor(ChatColor.YELLOW); |
| 874 | + renameButton.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, |
| 875 | + new ComponentBuilder("Change the name of the portal").create())); |
| 876 | + renameButton.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/portal rename ")); |
| 877 | + |
| 878 | + TextComponent activateButton = new TextComponent("Activate"); |
| 879 | + activateButton.setColor(ChatColor.YELLOW); |
| 880 | + activateButton.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, |
| 881 | + new ComponentBuilder("Trigger it as if you've just walked into it (Minus failing knockback)").create())); |
| 882 | + activateButton.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/portal warp " + portalName)); |
| 883 | + |
| 884 | + BaseComponent[] editMessage = new ComponentBuilder("Functions").color(ChatColor.GREEN) |
| 885 | + .append(": ").color(ChatColor.YELLOW) |
| 886 | + .append(removeButton).append(" ") |
| 887 | + .append(showButton).append(" ") |
| 888 | + .append(renameButton).append(" ") |
| 889 | + .append(activateButton).append(" ") |
| 890 | + .create(); |
| 891 | + |
| 892 | + sender.spigot().sendMessage(editMessage); |
| 893 | + |
| 894 | + /*player.spigot().sendMessage(TextComponent.fromLegacyText("{\"text\":\"\u00A7aFunctions\u00A7e: \"," |
831 | 895 | + "\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal gui remove "
|
832 | 896 | + portalName + "\"}}"
|
833 | 897 | + ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal show "
|
834 | 898 | + portalName + "\"}}"
|
835 | 899 | + ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
|
836 | 900 | + ",{\"text\":\" \"},{\"text\":\"\u00A7eTeleport\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(If there is one)\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/desti warp "
|
837 |
| - + destination + "\"}}]}", player); |
| 901 | + + destination + "\"}}]}"));*/ |
838 | 902 |
|
839 | 903 | sender.sendMessage("");
|
840 | 904 |
|
|
0 commit comments