Splits the PortalTeleporter into a PlayerTeleporter and a VehicleTeleporter for better structuring

Moves player-related teleportation code to PlayerTeleporter, moves vehicle-related teleportation code to VehicleTeleporter and makes them both extend the Teleporter which now contains all common teleportation code.
This commit is contained in:
2021-10-18 18:38:36 +02:00
parent f4ec5e05d6
commit 0506cf1b61
11 changed files with 512 additions and 458 deletions

View File

@ -1,9 +1,9 @@
package net.knarcraft.stargate.utility;
import net.knarcraft.stargate.Stargate;
import net.knarcraft.stargate.portal.PlayerTeleporter;
import net.knarcraft.stargate.portal.Portal;
import net.knarcraft.stargate.portal.PortalHandler;
import net.knarcraft.stargate.portal.PortalTeleporter;
import org.bukkit.entity.Player;
import java.io.ByteArrayInputStream;
@ -131,7 +131,7 @@ public final class BungeeHelper {
Stargate.logger.info(Stargate.getString("prefix") + "Bungee gate " + destination + " does not exist");
return;
}
new PortalTeleporter(destinationPortal).teleport(player, destinationPortal, null);
new PlayerTeleporter(destinationPortal, player).teleport(destinationPortal, null);
}
}

View File

@ -107,7 +107,7 @@ public final class EconomyHandler {
* Checks whether the given player can afford the given fee
*
* @param player <p>The player to check</p>
* @param cost <p>The fee to pay</p>
* @param cost <p>The fee to pay</p>
* @return <p>True if the player can afford to pay the fee</p>
*/
public static boolean canAffordFee(Player player, int cost) {

View File

@ -2,9 +2,9 @@ package net.knarcraft.stargate.utility;
import net.knarcraft.stargate.Stargate;
import net.knarcraft.stargate.event.StargateAccessEvent;
import net.knarcraft.stargate.portal.PlayerTeleporter;
import net.knarcraft.stargate.portal.Portal;
import net.knarcraft.stargate.portal.PortalOption;
import net.knarcraft.stargate.portal.PortalTeleporter;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
@ -390,7 +390,7 @@ public final class PermissionHelper {
// Not open for this player
if (!entrancePortal.isOpenFor(player)) {
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
new PortalTeleporter(entrancePortal).teleport(player, entrancePortal, event);
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
return true;
}
@ -402,7 +402,7 @@ public final class PermissionHelper {
//Player cannot access portal
if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destination)) {
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
new PortalTeleporter(entrancePortal).teleport(player, entrancePortal, event);
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
entrancePortal.close(false);
return true;
}