diff --git a/src/main/java/net/knarcraft/stargate/config/StargateConfig.java b/src/main/java/net/knarcraft/stargate/config/StargateConfig.java index 189b2c7..23cb4b7 100644 --- a/src/main/java/net/knarcraft/stargate/config/StargateConfig.java +++ b/src/main/java/net/knarcraft/stargate/config/StargateConfig.java @@ -464,7 +464,7 @@ public final class StargateConfig { */ @NotNull private String replacePluginFolderPath(@NotNull String input) { - Pattern pattern = Pattern.compile("(?i)^plugins/Stargate"); + Pattern pattern = Pattern.compile("(?i)^plugins[\\\\\\/]Stargate"); Matcher matcher = pattern.matcher(input); if (matcher.matches()) { return dataFolderPath + matcher.replaceAll(""); diff --git a/src/main/java/net/knarcraft/stargate/container/RelativeBlockVector.java b/src/main/java/net/knarcraft/stargate/container/RelativeBlockVector.java index e06d08e..5f904a5 100644 --- a/src/main/java/net/knarcraft/stargate/container/RelativeBlockVector.java +++ b/src/main/java/net/knarcraft/stargate/container/RelativeBlockVector.java @@ -64,36 +64,6 @@ public record RelativeBlockVector(int right, int down, int out) { return new RelativeBlockVector(-this.right, -this.down, -this.out); } - /** - * Gets the distance to the right relative to the origin - * - * @return
The distance to the right relative to the origin
- */ - @Override - public int right() { - return right; - } - - /** - * Gets the distance downward relative to the origin - * - * @returnThe distance downward relative to the origin
- */ - @Override - public int down() { - return down; - } - - /** - * Gets the distance outward relative to the origin - * - * @returnThe distance outward relative to the origin
- */ - @Override - public int out() { - return out; - } - @Override @NotNull public String toString() { diff --git a/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java b/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java index 7f8b418..04323e3 100644 --- a/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java +++ b/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java @@ -353,7 +353,7 @@ public class PlayerEventListener implements Listener { } //Prevent a double click caused by a Spigot bug - if (clickIsBug(event.getPlayer(), block)) { + if (clickIsBug(event.getPlayer())) { return; } @@ -425,10 +425,9 @@ public class PlayerEventListener implements Listener { * clicking once the bug is fixed. * * @param playerThe player performing the right-click
- * @param blockThe block to check
* @returnTrue if the click is a bug and should be cancelled
*/ - private boolean clickIsBug(@NotNull Player player, @NotNull Block block) { + private boolean clickIsBug(@NotNull Player player) { Long previousEventTime = previousEventTimes.get(player); if (previousEventTime != null && previousEventTime + 50 > System.currentTimeMillis()) { previousEventTimes.put(player, null); diff --git a/src/main/java/net/knarcraft/stargate/listener/VehicleEventListener.java b/src/main/java/net/knarcraft/stargate/listener/VehicleEventListener.java index b35b978..5de125a 100644 --- a/src/main/java/net/knarcraft/stargate/listener/VehicleEventListener.java +++ b/src/main/java/net/knarcraft/stargate/listener/VehicleEventListener.java @@ -116,16 +116,32 @@ public class VehicleEventListener implements Listener { return; } + // Perform the teleportation + teleportPlayerAndVehicle(players, vehicle, entrancePortal, destinationPortal); + } + + /** + * Performs the teleportation of one or more players in a vehicle + * + * @param playersThe players to be teleported
+ * @param vehicleThe vehicle that triggered the teleportation
+ * @param entrancePortalThe portal the player(s) and vehicle entered from
+ * @param destinationPortalThe portal the player(s) and vehicle are teleporting to
+ */ + private static void teleportPlayerAndVehicle(@NotNull ListObject containing locations of all relevant blocks
* @param buttonThe location of the portal's open button
- * @param destinationThe destination defined on the sign's destination line. "" for non-fixed gates
- * @param nameThe name of the portal defined on the sign's first line
- * @param networkThe network the portal belongs to, defined on the sign's third
+ * @param portalStringsThe portal's string values, such as name, network and destination
* @param gateThe gate type to use for this portal
* @param portalOwnerThe portal's owner
* @param optionsA map containing all possible portal options, with true for the ones enabled
*/ - public Portal(@NotNull PortalLocation portalLocation, @Nullable BlockLocation button, @NotNull String destination, - @NotNull String name, @NotNull String network, @NotNull Gate gate, @NotNull PortalOwner portalOwner, + public Portal(@NotNull PortalLocation portalLocation, @Nullable BlockLocation button, + @NotNull PortalStrings portalStrings, @NotNull Gate gate, @NotNull PortalOwner portalOwner, @NotNull MapThe name of the portal
+ * @param networkThe name of the network the portal belongs to
+ * @param destinationThe name of the portal's destination
+ */ +public record PortalStrings(@NotNull String name, @NotNull String network, @NotNull String destination) { +} diff --git a/src/main/java/net/knarcraft/stargate/utility/PortalFileHelper.java b/src/main/java/net/knarcraft/stargate/utility/PortalFileHelper.java index 98ff915..bfc8d8f 100644 --- a/src/main/java/net/knarcraft/stargate/utility/PortalFileHelper.java +++ b/src/main/java/net/knarcraft/stargate/utility/PortalFileHelper.java @@ -10,6 +10,7 @@ import net.knarcraft.stargate.portal.PortalRegistry; import net.knarcraft.stargate.portal.property.PortalLocation; import net.knarcraft.stargate.portal.property.PortalOptions; import net.knarcraft.stargate.portal.property.PortalOwner; +import net.knarcraft.stargate.portal.property.PortalStrings; import net.knarcraft.stargate.portal.property.gate.Gate; import net.knarcraft.stargate.portal.property.gate.GateHandler; import org.bukkit.Bukkit; @@ -286,7 +287,8 @@ public final class PortalFileHelper { PortalOwner owner = new PortalOwner(ownerString); //Create the new portal - Portal portal = new Portal(portalLocation, button, destination, name, network, gate, owner, + PortalStrings portalStrings = new PortalStrings(name, network, destination); + Portal portal = new Portal(portalLocation, button, portalStrings, gate, owner, PortalHandler.getPortalOptions(portalData)); //Register the portal, and close it in case it wasn't properly closed when the server stopped