Skip to content

Commit 1c413c8

Browse files
author
Sekwah
committed
Updated to 1.16
Solves #200 Also removed the compat file so this should be far more forwards compatible
1 parent 4012e9b commit 1c413c8

File tree

8 files changed

+113
-148
lines changed

8 files changed

+113
-148
lines changed

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ repositories {
4141

4242
// includeLibs just says to include the library in the final jar
4343
dependencies {
44-
implementation "org.bukkit:bukkit:1.15.1-R0.1-SNAPSHOT"
44+
//implementation "org.bukkit:bukkit:1.16.1-R0.1-SNAPSHOT"
45+
implementation "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
4546
implementation "net.md-5:bungeecord-api:1.15-SNAPSHOT"
4647

4748
implementation "io.netty:netty-all:4.0.4.Final"

src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java

+78-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import com.sekwah.advancedportals.bukkit.listeners.Listeners;
77
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
88
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.*;
912
import org.bukkit.DyeColor;
1013
import org.bukkit.Location;
1114
import org.bukkit.Material;
@@ -23,6 +26,7 @@
2326
import org.bukkit.material.Wool;
2427
import org.bukkit.metadata.FixedMetadataValue;
2528

29+
import javax.xml.soap.Text;
2630
import java.util.*;
2731
import java.util.stream.Collectors;
2832

@@ -462,21 +466,31 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
462466
player.sendMessage(PluginMessages.customPrefixFail + " You had no portal selected!");
463467
}
464468
case "gui":
469+
// /portal gui remove testarg
465470
if (args.length > 1) {
466471
if (args[1].toLowerCase().equals("remove") && args.length > 2) {
467472
sender.sendMessage("");
468473
sender.sendMessage(PluginMessages.customPrefixFail
469474
+ " Are you sure you would like to remove the portal \u00A7e" + args[2]
470475
+ "\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+
471492
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);
480494
sender.sendMessage("");
481495
}
482496
}
@@ -551,11 +565,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
551565
// TODO add the command autocompletes, add, remove and show
552566
if (args[1].toLowerCase().equals("add")) {
553567
if (args.length > 2) {
554-
String portalCommand = args[2];
568+
StringBuilder portalCommand = new StringBuilder(args[2]);
555569
for (int i = 3; i < args.length; i++) {
556-
portalCommand += args[i];
570+
portalCommand.append(args[i]);
557571
}
558-
if (Portal.addCommand(portalName, portalCommand)) {
572+
if (Portal.addCommand(portalName, portalCommand.toString())) {
559573
sender.sendMessage(
560574
PluginMessages.customPrefixFail + " Command added to portal!");
561575
} else {
@@ -826,15 +840,65 @@ private void portalEditMenu(CommandSender sender, ConfigAccessor portalConfig, S
826840
sender.sendMessage("");
827841

828842
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: \","
831895
+ "\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal gui remove "
832896
+ portalName + "\"}}"
833897
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal show "
834898
+ portalName + "\"}}"
835899
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
836900
+ ",{\"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 + "\"}}]}"));*/
838902

839903
sender.sendMessage("");
840904

src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java

+24-38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.sekwah.advancedportals.bukkit;
22

3-
import com.sekwah.advancedportals.bukkit.compat.CraftBukkit;
43
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
54
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
65
import com.sekwah.advancedportals.bukkit.destinations.Destination;
@@ -14,7 +13,7 @@
1413

1514
public class AdvancedPortalsPlugin extends JavaPlugin {
1615

17-
public CraftBukkit compat = null;
16+
//public CraftBukkit compat = null;
1817
private Settings settings;
1918

2019
public String channelName = "mc:advancedportals";
@@ -29,65 +28,52 @@ public void onEnable() {
2928

3029
saveDefaultConfig();
3130

32-
Metrics metrics = new Metrics(this);
31+
/*Metrics metrics = */
32+
new Metrics(this);
3333

34-
try {
3534

36-
this.compat = new CraftBukkit(this, version);
35+
//this.compat = new CraftBukkit(this, version);
3736

38-
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
37+
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
3938

40-
ConfigHelper configHelper = new ConfigHelper(config.getConfig());
39+
ConfigHelper configHelper = new ConfigHelper(config.getConfig());
4140

42-
configHelper.update();
41+
configHelper.update();
4342

44-
config.saveConfig();
43+
config.saveConfig();
4544

46-
// TODO reenable and finish but probably focus on the recode first
45+
// TODO reenable and finish but probably focus on the recode first
4746
/*if(config.getConfig().getBoolean("DisableGatewayBeam", true)) {
4847
new PacketInjector(this, version);
4948
}*/
5049

51-
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
52-
portalConfig.saveDefaultConfig();
50+
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
51+
portalConfig.saveDefaultConfig();
5352

5453

55-
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
56-
destinationConfig.saveDefaultConfig();
54+
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
55+
destinationConfig.saveDefaultConfig();
5756

58-
this.settings = new Settings(this);
57+
this.settings = new Settings(this);
5958

60-
// Loads the portal and destination editors
61-
new Portal(this);
62-
new Destination(this);
59+
// Loads the portal and destination editors
60+
new Portal(this);
61+
new Destination(this);
6362

6463

65-
this.registerCommands();
64+
this.registerCommands();
6665

67-
new WarpEffects(this);
66+
new WarpEffects(this);
6867

69-
this.addListeners();
70-
this.setupDataCollector();
68+
this.addListeners();
69+
this.setupDataCollector();
7170

72-
this.setupBungee();
71+
this.setupBungee();
7372

74-
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
75-
76-
} catch (ClassNotFoundException e) {
77-
e.printStackTrace();
78-
this.getLogger().warning("This version of craftbukkit is not yet supported, please notify sekwah and tell him about this version v:" + version);
79-
this.getLogger().warning("Along with the above stacktrace");
80-
this.setEnabled(false);
81-
} catch (IllegalArgumentException |
82-
NoSuchFieldException | SecurityException | NoSuchMethodException e) {
83-
e.printStackTrace();
84-
this.getLogger().warning("Something went wrong, please notify sekwah and tell him about this version v:" + version);
85-
this.getLogger().warning("Along with the above stacktrace");
86-
this.setEnabled(false);
87-
}
73+
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
8874

8975
for (Player player:
90-
this.getServer().getOnlinePlayers()) {
76+
this.getServer().getOnlinePlayers()) {
9177
player.removeMetadata("hasWarped", this);
9278
player.removeMetadata("lavaWarped", this);
9379
}

src/main/java/com/sekwah/advancedportals/bukkit/compat/CraftBukkit.java

-90
This file was deleted.

src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
55
import com.sekwah.advancedportals.bukkit.PluginMessages;
66
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
7+
import net.md_5.bungee.api.ChatMessageType;
8+
import net.md_5.bungee.api.chat.TextComponent;
79
import org.bukkit.Bukkit;
810
import org.bukkit.Chunk;
911
import org.bukkit.Location;
@@ -150,7 +152,7 @@ public static boolean warp(Player player, String name, boolean hideActionbar, bo
150152
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.");
151153
player.sendMessage("");
152154
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
153-
plugin.compat.sendActionBarMessage("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.", player);
155+
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a."));
154156
}
155157

156158
return true;

0 commit comments

Comments
 (0)