Alters the RegEx for replacing the plugin folder path
This commit is contained in:
@@ -464,7 +464,7 @@ public final class StargateConfig {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private String replacePluginFolderPath(@NotNull String input) {
|
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);
|
Matcher matcher = pattern.matcher(input);
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
return dataFolderPath + matcher.replaceAll("");
|
return dataFolderPath + matcher.replaceAll("");
|
||||||
|
@@ -64,36 +64,6 @@ public record RelativeBlockVector(int right, int down, int out) {
|
|||||||
return new RelativeBlockVector(-this.right, -this.down, -this.out);
|
return new RelativeBlockVector(-this.right, -this.down, -this.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the distance to the right relative to the origin
|
|
||||||
*
|
|
||||||
* @return <p>The distance to the right relative to the origin</p>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int right() {
|
|
||||||
return right;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the distance downward relative to the origin
|
|
||||||
*
|
|
||||||
* @return <p>The distance downward relative to the origin</p>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int down() {
|
|
||||||
return down;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the distance outward relative to the origin
|
|
||||||
*
|
|
||||||
* @return <p>The distance outward relative to the origin</p>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int out() {
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@@ -353,7 +353,7 @@ public class PlayerEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Prevent a double click caused by a Spigot bug
|
//Prevent a double click caused by a Spigot bug
|
||||||
if (clickIsBug(event.getPlayer(), block)) {
|
if (clickIsBug(event.getPlayer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,10 +425,9 @@ public class PlayerEventListener implements Listener {
|
|||||||
* clicking once the bug is fixed.</p>
|
* clicking once the bug is fixed.</p>
|
||||||
*
|
*
|
||||||
* @param player <p>The player performing the right-click</p>
|
* @param player <p>The player performing the right-click</p>
|
||||||
* @param block <p>The block to check</p>
|
|
||||||
* @return <p>True if the click is a bug and should be cancelled</p>
|
* @return <p>True if the click is a bug and should be cancelled</p>
|
||||||
*/
|
*/
|
||||||
private boolean clickIsBug(@NotNull Player player, @NotNull Block block) {
|
private boolean clickIsBug(@NotNull Player player) {
|
||||||
Long previousEventTime = previousEventTimes.get(player);
|
Long previousEventTime = previousEventTimes.get(player);
|
||||||
if (previousEventTime != null && previousEventTime + 50 > System.currentTimeMillis()) {
|
if (previousEventTime != null && previousEventTime + 50 > System.currentTimeMillis()) {
|
||||||
previousEventTimes.put(player, null);
|
previousEventTimes.put(player, null);
|
||||||
|
@@ -116,16 +116,32 @@ public class VehicleEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Perform the teleportation
|
||||||
|
teleportPlayerAndVehicle(players, vehicle, entrancePortal, destinationPortal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the teleportation of one or more players in a vehicle
|
||||||
|
*
|
||||||
|
* @param players <p>The players to be teleported</p>
|
||||||
|
* @param vehicle <p>The vehicle that triggered the teleportation</p>
|
||||||
|
* @param entrancePortal <p>The portal the player(s) and vehicle entered from</p>
|
||||||
|
* @param destinationPortal <p>The portal the player(s) and vehicle are teleporting to</p>
|
||||||
|
*/
|
||||||
|
private static void teleportPlayerAndVehicle(@NotNull List<Player> players, @NotNull Vehicle vehicle,
|
||||||
|
@NotNull Portal entrancePortal, @NotNull Portal destinationPortal) {
|
||||||
//Teleport the vehicle and inform the user if the vehicle was teleported
|
//Teleport the vehicle and inform the user if the vehicle was teleported
|
||||||
boolean teleported = new VehicleTeleporter(destinationPortal, vehicle).teleportEntity(entrancePortal);
|
boolean teleported = new VehicleTeleporter(destinationPortal, vehicle).teleportEntity(entrancePortal);
|
||||||
if (teleported) {
|
if (!teleported) {
|
||||||
if (!entrancePortal.getOptions().isSilent()) {
|
return;
|
||||||
for (Player player : players) {
|
|
||||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.TELEPORTED));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entrancePortal.getPortalOpener().closePortal(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!entrancePortal.getOptions().isSilent()) {
|
||||||
|
for (Player player : players) {
|
||||||
|
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.TELEPORTED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entrancePortal.getPortalOpener().closePortal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,6 +6,7 @@ import net.knarcraft.stargate.portal.property.PortalLocation;
|
|||||||
import net.knarcraft.stargate.portal.property.PortalOption;
|
import net.knarcraft.stargate.portal.property.PortalOption;
|
||||||
import net.knarcraft.stargate.portal.property.PortalOptions;
|
import net.knarcraft.stargate.portal.property.PortalOptions;
|
||||||
import net.knarcraft.stargate.portal.property.PortalOwner;
|
import net.knarcraft.stargate.portal.property.PortalOwner;
|
||||||
|
import net.knarcraft.stargate.portal.property.PortalStrings;
|
||||||
import net.knarcraft.stargate.portal.property.PortalStructure;
|
import net.knarcraft.stargate.portal.property.PortalStructure;
|
||||||
import net.knarcraft.stargate.portal.property.gate.Gate;
|
import net.knarcraft.stargate.portal.property.gate.Gate;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@@ -41,23 +42,21 @@ public class Portal {
|
|||||||
*
|
*
|
||||||
* @param portalLocation <p>Object containing locations of all relevant blocks</p>
|
* @param portalLocation <p>Object containing locations of all relevant blocks</p>
|
||||||
* @param button <p>The location of the portal's open button</p>
|
* @param button <p>The location of the portal's open button</p>
|
||||||
* @param destination <p>The destination defined on the sign's destination line. "" for non-fixed gates</p>
|
* @param portalStrings <p>The portal's string values, such as name, network and destination</p>
|
||||||
* @param name <p>The name of the portal defined on the sign's first line</p>
|
|
||||||
* @param network <p>The network the portal belongs to, defined on the sign's third</p>
|
|
||||||
* @param gate <p>The gate type to use for this portal</p>
|
* @param gate <p>The gate type to use for this portal</p>
|
||||||
* @param portalOwner <p>The portal's owner</p>
|
* @param portalOwner <p>The portal's owner</p>
|
||||||
* @param options <p>A map containing all possible portal options, with true for the ones enabled</p>
|
* @param options <p>A map containing all possible portal options, with true for the ones enabled</p>
|
||||||
*/
|
*/
|
||||||
public Portal(@NotNull PortalLocation portalLocation, @Nullable BlockLocation button, @NotNull String destination,
|
public Portal(@NotNull PortalLocation portalLocation, @Nullable BlockLocation button,
|
||||||
@NotNull String name, @NotNull String network, @NotNull Gate gate, @NotNull PortalOwner portalOwner,
|
@NotNull PortalStrings portalStrings, @NotNull Gate gate, @NotNull PortalOwner portalOwner,
|
||||||
@NotNull Map<PortalOption, Boolean> options) {
|
@NotNull Map<PortalOption, Boolean> options) {
|
||||||
this.location = portalLocation;
|
this.location = portalLocation;
|
||||||
this.network = network;
|
this.network = portalStrings.network();
|
||||||
this.name = name;
|
this.name = portalStrings.name();
|
||||||
this.portalOwner = portalOwner;
|
this.portalOwner = portalOwner;
|
||||||
this.options = new PortalOptions(options, destination.length() > 0);
|
this.options = new PortalOptions(options, portalStrings.destination().length() > 0);
|
||||||
this.signDrawer = new PortalSignDrawer(this);
|
this.signDrawer = new PortalSignDrawer(this);
|
||||||
this.portalOpener = new PortalOpener(this, destination);
|
this.portalOpener = new PortalOpener(this, portalStrings.destination());
|
||||||
this.structure = new PortalStructure(this, gate, button);
|
this.structure = new PortalStructure(this, gate, button);
|
||||||
this.portalActivator = portalOpener.getPortalActivator();
|
this.portalActivator = portalOpener.getPortalActivator();
|
||||||
this.cleanName = cleanString(name);
|
this.cleanName = cleanString(name);
|
||||||
|
@@ -78,8 +78,8 @@ public class PortalActivator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//Get one random destination
|
//Get one random destination
|
||||||
String destination = ListHelper.getRandom(destinations);
|
String randomDestination = ListHelper.getRandom(destinations);
|
||||||
return PortalHandler.getByName(Portal.cleanString(destination), portalNetwork);
|
return PortalHandler.getByName(Portal.cleanString(randomDestination), portalNetwork);
|
||||||
} else {
|
} else {
|
||||||
//Just return the normal fixed destination
|
//Just return the normal fixed destination
|
||||||
return PortalHandler.getByName(Portal.cleanString(destination), portalNetwork);
|
return PortalHandler.getByName(Portal.cleanString(destination), portalNetwork);
|
||||||
|
@@ -9,6 +9,7 @@ import net.knarcraft.stargate.portal.property.PortalLocation;
|
|||||||
import net.knarcraft.stargate.portal.property.PortalOption;
|
import net.knarcraft.stargate.portal.property.PortalOption;
|
||||||
import net.knarcraft.stargate.portal.property.PortalOptions;
|
import net.knarcraft.stargate.portal.property.PortalOptions;
|
||||||
import net.knarcraft.stargate.portal.property.PortalOwner;
|
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.Gate;
|
||||||
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
||||||
import net.knarcraft.stargate.utility.DirectionHelper;
|
import net.knarcraft.stargate.utility.DirectionHelper;
|
||||||
@@ -167,8 +168,8 @@ public class PortalCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PortalOwner owner = new PortalOwner(player);
|
PortalOwner owner = new PortalOwner(player);
|
||||||
this.portal = new Portal(portalLocation, null, destinationName, portalName, network, gate, owner,
|
PortalStrings portalStrings = new PortalStrings(portalName, network, destinationName);
|
||||||
portalOptions);
|
this.portal = new Portal(portalLocation, null, portalStrings, gate, owner, portalOptions);
|
||||||
return validatePortal(denyMessage, event.getLines(), deny);
|
return validatePortal(denyMessage, event.getLines(), deny);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
package net.knarcraft.stargate.portal.property;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A record of a portal's string values
|
||||||
|
*
|
||||||
|
* @param name <p>The name of the portal</p>
|
||||||
|
* @param network <p>The name of the network the portal belongs to</p>
|
||||||
|
* @param destination <p>The name of the portal's destination</p>
|
||||||
|
*/
|
||||||
|
public record PortalStrings(@NotNull String name, @NotNull String network, @NotNull String destination) {
|
||||||
|
}
|
@@ -10,6 +10,7 @@ import net.knarcraft.stargate.portal.PortalRegistry;
|
|||||||
import net.knarcraft.stargate.portal.property.PortalLocation;
|
import net.knarcraft.stargate.portal.property.PortalLocation;
|
||||||
import net.knarcraft.stargate.portal.property.PortalOptions;
|
import net.knarcraft.stargate.portal.property.PortalOptions;
|
||||||
import net.knarcraft.stargate.portal.property.PortalOwner;
|
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.Gate;
|
||||||
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -286,7 +287,8 @@ public final class PortalFileHelper {
|
|||||||
PortalOwner owner = new PortalOwner(ownerString);
|
PortalOwner owner = new PortalOwner(ownerString);
|
||||||
|
|
||||||
//Create the new portal
|
//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));
|
PortalHandler.getPortalOptions(portalData));
|
||||||
|
|
||||||
//Register the portal, and close it in case it wasn't properly closed when the server stopped
|
//Register the portal, and close it in case it wasn't properly closed when the server stopped
|
||||||
|
Reference in New Issue
Block a user