mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +00:00
Adjust connection getting during teleport to fix expired connection error
This commit is contained in:
1 parent
4e2488399d
commit
9943d2c9d5
11 files changed
+43
-64
No files matched your search
@@ -246,14 +246,10 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public void teleportPlayer(Player player, TeleportationPoint point, boolean timed) {
|
public void teleportPlayer(Player player, TeleportationPoint point, boolean timed) {
|
||||||
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
|
||||||
if (timed) {
|
if (timed) {
|
||||||
TeleportManager.queueTimedTeleport(player, point, connection);
|
TeleportManager.queueTimedTeleport(player, point);
|
||||||
} else {
|
} else {
|
||||||
TeleportManager.teleportPlayer(player, point, connection);
|
TeleportManager.teleportPlayer(player, point);
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred timed-teleporting a player via the API.");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -268,14 +264,10 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public void teleportPlayer(Player player, String targetPlayerName, boolean timed) {
|
public void teleportPlayer(Player player, String targetPlayerName, boolean timed) {
|
||||||
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
|
||||||
if (timed) {
|
if (timed) {
|
||||||
TeleportManager.queueTimedTeleport(player, targetPlayerName, connection);
|
TeleportManager.queueTimedTeleport(player, targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
TeleportManager.teleportPlayer(player, targetPlayerName, connection);
|
TeleportManager.teleportPlayer(player, targetPlayerName);
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQLException occurred teleporting a player via API");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class HomeCommand extends CommandBase {
|
|||||||
PublicHomeCommand.queueHomeTeleport(p, homeArgument);
|
PublicHomeCommand.queueHomeTeleport(p, homeArgument);
|
||||||
} else if (DataManager.homeExists(p, homeArgument, connection)) {
|
} else if (DataManager.homeExists(p, homeArgument, connection)) {
|
||||||
Home home = DataManager.getHome(p.getName(), homeArgument, connection);
|
Home home = DataManager.getHome(p.getName(), homeArgument, connection);
|
||||||
TeleportManager.queueTimedTeleport(p, home, connection);
|
TeleportManager.queueTimedTeleport(p, home);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_home_invalid", homeArgument);
|
MessageManager.sendMessage(p, "error_home_invalid", homeArgument);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public class HomeCommand extends CommandBase {
|
|||||||
List<Home> homes = DataManager.getPlayerHomes(p.getName(), connection);
|
List<Home> homes = DataManager.getPlayerHomes(p.getName(), connection);
|
||||||
if (homes.size() == 1) {
|
if (homes.size() == 1) {
|
||||||
// Teleport the player if they only have one home
|
// Teleport the player if they only have one home
|
||||||
TeleportManager.queueTimedTeleport(p, homes.get(0), connection);
|
TeleportManager.queueTimedTeleport(p, homes.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HomeListCommand.displayPlayerHomeList(p, p.getName(), 1);
|
HomeListCommand.displayPlayerHomeList(p, p.getName(), 1);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
|
|||||||
Home home = DataManager.getHome(ownerName, homeName, connection);
|
Home home = DataManager.getHome(ownerName, homeName, connection);
|
||||||
assert home != null;
|
assert home != null;
|
||||||
if (home.isPublic() || p.getName().equalsIgnoreCase(ownerName) || p.hasPermission("huskhomes.home.other")) {
|
if (home.isPublic() || p.getName().equalsIgnoreCase(ownerName) || p.hasPermission("huskhomes.home.other")) {
|
||||||
TeleportManager.queueTimedTeleport(p, home, connection);
|
TeleportManager.queueTimedTeleport(p, home);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
|
|||||||
if (!home.isPublic()) {
|
if (!home.isPublic()) {
|
||||||
sender.sendMessage("Warning: Bypassed home security (" + home.getName() + " was not set to public by " + home.getOwnerUsername() + ")");
|
sender.sendMessage("Warning: Bypassed home security (" + home.getName() + " was not set to public by " + home.getOwnerUsername() + ")");
|
||||||
}
|
}
|
||||||
TeleportManager.teleportPlayer(targetPlayer, home, connection);
|
TeleportManager.teleportPlayer(targetPlayer, home);
|
||||||
sender.sendMessage("Successfully teleported player!");
|
sender.sendMessage("Successfully teleported player!");
|
||||||
MessageManager.sendMessage(targetPlayer, "teleporting_complete_console", (home.getOwnerUsername() + "." + homeName));
|
MessageManager.sendMessage(targetPlayer, "teleporting_complete_console", (home.getOwnerUsername() + "." + homeName));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class SpawnCommand extends CommandBase {
|
|||||||
// Cross server spawn teleport
|
// Cross server spawn teleport
|
||||||
if (HuskHomes.getSettings().doCrossServerSpawn()) {
|
if (HuskHomes.getSettings().doCrossServerSpawn()) {
|
||||||
if (DataManager.warpExists(spawnWarpName, connection)) {
|
if (DataManager.warpExists(spawnWarpName, connection)) {
|
||||||
TeleportManager.queueTimedTeleport(p, DataManager.getWarp(spawnWarpName, connection), connection);
|
TeleportManager.queueTimedTeleport(p, DataManager.getWarp(spawnWarpName, connection));
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public class SpawnCommand extends CommandBase {
|
|||||||
|
|
||||||
// Server-based spawn teleport
|
// Server-based spawn teleport
|
||||||
if (TeleportManager.getSpawnLocation() != null) {
|
if (TeleportManager.getSpawnLocation() != null) {
|
||||||
TeleportManager.queueTimedTeleport(p, TeleportManager.getSpawnLocation(), connection);
|
TeleportManager.queueTimedTeleport(p, TeleportManager.getSpawnLocation());
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class TpCommand extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
@@ -35,7 +34,7 @@ public class TpCommand extends CommandBase {
|
|||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
String targetPlayer = args[0];
|
String targetPlayer = args[0];
|
||||||
TeleportManager.teleportPlayer(p, NameAutoCompleter.getAutoCompletedName(targetPlayer), connection);
|
TeleportManager.teleportPlayer(p, NameAutoCompleter.getAutoCompletedName(targetPlayer));
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
try {
|
try {
|
||||||
@@ -43,7 +42,7 @@ public class TpCommand extends CommandBase {
|
|||||||
double y = Double.parseDouble(args[1]);
|
double y = Double.parseDouble(args[1]);
|
||||||
double z = Double.parseDouble(args[2]);
|
double z = Double.parseDouble(args[2]);
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.getSettings().getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.getSettings().getServerID());
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
}
|
}
|
||||||
@@ -59,7 +58,7 @@ public class TpCommand extends CommandBase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.getSettings().getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.getSettings().getServerID());
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,7 @@ public class TpCommand extends CommandBase {
|
|||||||
String worldName = args[3];
|
String worldName = args[3];
|
||||||
String serverName = args[4];
|
String serverName = args[4];
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName);
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName);
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||||
}
|
}
|
||||||
@@ -90,7 +89,7 @@ public class TpCommand extends CommandBase {
|
|||||||
float yaw = Float.parseFloat(args[4]);
|
float yaw = Float.parseFloat(args[4]);
|
||||||
float pitch = Float.parseFloat(args[5]);
|
float pitch = Float.parseFloat(args[5]);
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, yaw, pitch, HuskHomes.getSettings().getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, yaw, pitch, HuskHomes.getSettings().getServerID());
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <yaw> <pitch>");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <yaw> <pitch>");
|
||||||
}
|
}
|
||||||
@@ -105,7 +104,7 @@ public class TpCommand extends CommandBase {
|
|||||||
float yaw = Float.parseFloat(args[5]);
|
float yaw = Float.parseFloat(args[5]);
|
||||||
float pitch = Float.parseFloat(args[6]);
|
float pitch = Float.parseFloat(args[6]);
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, yaw, pitch, serverName);
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, yaw, pitch, serverName);
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server> <yaw> <pitch>");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server> <yaw> <pitch>");
|
||||||
}
|
}
|
||||||
@@ -113,9 +112,6 @@ public class TpCommand extends CommandBase {
|
|||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred while using /tp", e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class TpHereCommand extends CommandBase {
|
|||||||
String targetPlayer = args[0];
|
String targetPlayer = args[0];
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
try (Connection connection = HuskHomes.getConnection()) {
|
||||||
TeleportManager.teleportHere(p, NameAutoCompleter.getAutoCompletedName(targetPlayer), connection);
|
TeleportManager.teleportHere(p, NameAutoCompleter.getAutoCompletedName(targetPlayer));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred using /tphere");
|
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred using /tphere");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class WarpCommand extends CommandBase {
|
|||||||
if (DataManager.warpExists(warpName, connection)) {
|
if (DataManager.warpExists(warpName, connection)) {
|
||||||
if (Warp.getWarpCanUse(p, warpName)) {
|
if (Warp.getWarpCanUse(p, warpName)) {
|
||||||
Warp warp = DataManager.getWarp(warpName, connection);
|
Warp warp = DataManager.getWarp(warpName, connection);
|
||||||
TeleportManager.queueTimedTeleport(p, warp, connection);
|
TeleportManager.queueTimedTeleport(p, warp);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_permission_restricted_warp", warpName);
|
MessageManager.sendMessage(p, "error_permission_restricted_warp", warpName);
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ public class WarpCommand extends CommandBase {
|
|||||||
try (Connection connection = HuskHomes.getConnection()) {
|
try (Connection connection = HuskHomes.getConnection()) {
|
||||||
if (DataManager.warpExists(warpName, connection)) {
|
if (DataManager.warpExists(warpName, connection)) {
|
||||||
Warp warp = DataManager.getWarp(warpName, connection);
|
Warp warp = DataManager.getWarp(warpName, connection);
|
||||||
TeleportManager.teleportPlayer(targetPlayer, warp, connection);
|
TeleportManager.teleportPlayer(targetPlayer, warp);
|
||||||
sender.sendMessage("Successfully warped player!");
|
sender.sendMessage("Successfully warped player!");
|
||||||
MessageManager.sendMessage(targetPlayer, "teleporting_complete_console", warpName);
|
MessageManager.sendMessage(targetPlayer, "teleporting_complete_console", warpName);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class CrossServerMessageHandler {
|
|||||||
MessageManager.sendMessage(recipient, "tpa_has_accepted", tpaReplierName);
|
MessageManager.sendMessage(recipient, "tpa_has_accepted", tpaReplierName);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
try (Connection connection = HuskHomes.getConnection()) {
|
||||||
TeleportManager.queueTimedTeleport(recipient, tpaReplierName, connection);
|
TeleportManager.queueTimedTeleport(recipient, tpaReplierName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport request reply");
|
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport request reply");
|
||||||
}
|
}
|
||||||
@@ -94,13 +94,7 @@ public class CrossServerMessageHandler {
|
|||||||
MessageManager.sendMessage(recipient, "tpa_has_declined", tpaHereReplierName);
|
MessageManager.sendMessage(recipient, "tpa_has_declined", tpaHereReplierName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case TELEPORT_TO_ME -> Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
case TELEPORT_TO_ME -> Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> TeleportManager.teleportPlayer(recipient, receivedMessage.getMessageData()));
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
|
||||||
TeleportManager.teleportPlayer(recipient, receivedMessage.getMessageData(), connection);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport-to-me request");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
case GET_PLAYER_LIST -> {
|
case GET_PLAYER_LIST -> {
|
||||||
final String requestingServer = receivedMessage.getMessageData();
|
final String requestingServer = receivedMessage.getMessageData();
|
||||||
StringJoiner playerList = new StringJoiner("£");
|
StringJoiner playerList = new StringJoiner("£");
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class TeleportManager {
|
public class TeleportManager {
|
||||||
@@ -35,13 +34,14 @@ public class TeleportManager {
|
|||||||
return preTeleportEvent.isCancelled();
|
return preTeleportEvent.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportPlayer(Player player, String targetPlayer, Connection connection) {
|
// Teleport a player to a player by name
|
||||||
|
public static void teleportPlayer(Player player, String targetPlayer) {
|
||||||
final TeleportationPoint destination = new TeleportationPoint(player.getLocation(),
|
final TeleportationPoint destination = new TeleportationPoint(player.getLocation(),
|
||||||
HuskHomes.getSettings().getServerID());
|
HuskHomes.getSettings().getServerID());
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
if (isEventCancelled(player, destination)) return;
|
if (isEventCancelled(player, destination)) return;
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try {
|
try (Connection connection = HuskHomes.getConnection()) {
|
||||||
DataManager.setPlayerLastPosition(player, destination, connection);
|
DataManager.setPlayerLastPosition(player, destination, connection);
|
||||||
setPlayerDestinationFromTargetPlayer(player, targetPlayer, connection);
|
setPlayerDestinationFromTargetPlayer(player, targetPlayer, connection);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -51,13 +51,14 @@ public class TeleportManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportPlayer(Player player, TeleportationPoint point, Connection connection) {
|
// Teleport a player to a location on the server or proxy server network
|
||||||
|
public static void teleportPlayer(Player player, TeleportationPoint point) {
|
||||||
final TeleportationPoint destination = new TeleportationPoint(player.getLocation(),
|
final TeleportationPoint destination = new TeleportationPoint(player.getLocation(),
|
||||||
HuskHomes.getSettings().getServerID());
|
HuskHomes.getSettings().getServerID());
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
if (isEventCancelled(player, destination)) return;
|
if (isEventCancelled(player, destination)) return;
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try {
|
try (Connection connection = HuskHomes.getConnection()) {
|
||||||
DataManager.setPlayerLastPosition(player, destination, connection);
|
DataManager.setPlayerLastPosition(player, destination, connection);
|
||||||
DataManager.setPlayerDestinationLocation(player, point, connection);
|
DataManager.setPlayerDestinationLocation(player, point, connection);
|
||||||
teleportPlayer(player);
|
teleportPlayer(player);
|
||||||
@@ -107,18 +108,18 @@ public class TeleportManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueTimedTeleport(Player player, String targetPlayer, Connection connection) throws SQLException {
|
public static void queueTimedTeleport(Player player, String targetPlayer) {
|
||||||
if (player.hasPermission("huskhomes.bypass_timer")) {
|
if (player.hasPermission("huskhomes.bypass_timer")) {
|
||||||
teleportPlayer(player, targetPlayer, connection);
|
teleportPlayer(player, targetPlayer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new TimedTeleport(player, targetPlayer).begin();
|
new TimedTeleport(player, targetPlayer).begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueTimedTeleport(Player player, TeleportationPoint point, Connection connection) throws SQLException {
|
public static void queueTimedTeleport(Player player, TeleportationPoint point) {
|
||||||
if (player.hasPermission("huskhomes.bypass_timer")) {
|
if (player.hasPermission("huskhomes.bypass_timer")) {
|
||||||
teleportPlayer(player, point, connection);
|
teleportPlayer(player, point);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ public class TeleportManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageManager.sendMessage(player, "teleporting_offline_player", targetPlayer);
|
MessageManager.sendMessage(player, "teleporting_offline_player", targetPlayer);
|
||||||
teleportPlayer(player, offlinePoint, connection);
|
teleportPlayer(player, offlinePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueBackTeleport(Player player, Connection connection) throws SQLException {
|
public static void queueBackTeleport(Player player, Connection connection) throws SQLException {
|
||||||
@@ -161,7 +162,7 @@ public class TeleportManager {
|
|||||||
MessageManager.sendMessage(player, "back_spent_money", VaultIntegration.format(backCost));
|
MessageManager.sendMessage(player, "back_spent_money", VaultIntegration.format(backCost));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
teleportPlayer(player, lastPosition, connection);
|
teleportPlayer(player, lastPosition);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,18 +208,18 @@ public class TeleportManager {
|
|||||||
MessageManager.sendMessage(player, "rtp_spent_money", VaultIntegration.format(rtpCost));
|
MessageManager.sendMessage(player, "rtp_spent_money", VaultIntegration.format(rtpCost));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
teleportPlayer(player, randomPoint, connection);
|
teleportPlayer(player, randomPoint);
|
||||||
DataManager.updateRtpCoolDown(player, connection);
|
DataManager.updateRtpCoolDown(player, connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new TimedTeleport(player).begin();
|
new TimedTeleport(player).begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportHere(Player requester, String targetPlayerName, Connection connection) throws SQLException {
|
public static void teleportHere(Player requester, String targetPlayerName) throws SQLException {
|
||||||
Player targetPlayer = Bukkit.getPlayerExact(targetPlayerName);
|
Player targetPlayer = Bukkit.getPlayerExact(targetPlayerName);
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
if (targetPlayer.getUniqueId() != requester.getUniqueId()) {
|
if (targetPlayer.getUniqueId() != requester.getUniqueId()) {
|
||||||
teleportPlayer(targetPlayer, requester.getName(), connection);
|
teleportPlayer(targetPlayer, requester.getName());
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(requester, "error_tp_self");
|
MessageManager.sendMessage(requester, "error_tp_self");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,16 +108,15 @@ public class TeleportRequestHandler {
|
|||||||
Player requester = Bukkit.getPlayer(requesterName);
|
Player requester = Bukkit.getPlayer(requesterName);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try (Connection connection = HuskHomes.getConnection()) {
|
|
||||||
if (requester != null) {
|
if (requester != null) {
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
||||||
MessageManager.sendMessage(requester, "tpa_has_accepted", p.getName());
|
MessageManager.sendMessage(requester, "tpa_has_accepted", p.getName());
|
||||||
|
|
||||||
if (requestType == TeleportRequest.RequestType.TPA) {
|
if (requestType == TeleportRequest.RequestType.TPA) {
|
||||||
TeleportManager.queueTimedTeleport(requester, p.getName(), connection);
|
TeleportManager.queueTimedTeleport(requester, p.getName());
|
||||||
} else if (requestType == TeleportRequest.RequestType.TPA_HERE) {
|
} else if (requestType == TeleportRequest.RequestType.TPA_HERE) {
|
||||||
TeleportManager.queueTimedTeleport(p, requesterName, connection);
|
TeleportManager.queueTimedTeleport(p, requesterName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "tpa_you_declined", requesterName);
|
MessageManager.sendMessage(p, "tpa_you_declined", requesterName);
|
||||||
@@ -129,7 +128,7 @@ public class TeleportRequestHandler {
|
|||||||
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
||||||
replyTeleportRequestCrossServer(p, requesterName, requestType, true);
|
replyTeleportRequestCrossServer(p, requesterName, requestType, true);
|
||||||
if (requestType == TeleportRequest.RequestType.TPA_HERE) {
|
if (requestType == TeleportRequest.RequestType.TPA_HERE) {
|
||||||
TeleportManager.queueTimedTeleport(p, requesterName, connection);
|
TeleportManager.queueTimedTeleport(p, requesterName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
replyTeleportRequestCrossServer(p, requesterName, requestType, false);
|
replyTeleportRequestCrossServer(p, requesterName, requestType, false);
|
||||||
@@ -143,9 +142,6 @@ public class TeleportRequestHandler {
|
|||||||
if (teleportRequests.get(p).isEmpty()) {
|
if (teleportRequests.get(p).isEmpty()) {
|
||||||
teleportRequests.remove(p);
|
teleportRequests.remove(p);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred!", e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class TimedTeleport {
|
|||||||
try (Connection connection = HuskHomes.getConnection()) {
|
try (Connection connection = HuskHomes.getConnection()) {
|
||||||
// Execute the teleport
|
// Execute the teleport
|
||||||
switch (getTargetType()) {
|
switch (getTargetType()) {
|
||||||
case POINT -> TeleportManager.teleportPlayer(player, targetPoint, connection);
|
case POINT -> TeleportManager.teleportPlayer(player, targetPoint);
|
||||||
case BACK -> {
|
case BACK -> {
|
||||||
if (HuskHomes.getSettings().doEconomy()) {
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
double backCost = HuskHomes.getSettings().getBackCost();
|
double backCost = HuskHomes.getSettings().getBackCost();
|
||||||
@@ -108,9 +108,9 @@ public class TimedTeleport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TeleportManager.teleportPlayer(player, getTargetPoint(), connection);
|
TeleportManager.teleportPlayer(player, getTargetPoint());
|
||||||
}
|
}
|
||||||
case PLAYER -> TeleportManager.teleportPlayer(player, getTargetPlayerName(), connection);
|
case PLAYER -> TeleportManager.teleportPlayer(player, getTargetPlayerName());
|
||||||
case RANDOM -> {
|
case RANDOM -> {
|
||||||
RandomPoint randomPoint = new RandomPoint(player);
|
RandomPoint randomPoint = new RandomPoint(player);
|
||||||
if (randomPoint.hasFailed()) {
|
if (randomPoint.hasFailed()) {
|
||||||
@@ -127,7 +127,7 @@ public class TimedTeleport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TeleportManager.teleportPlayer(player, randomPoint, connection);
|
TeleportManager.teleportPlayer(player, randomPoint);
|
||||||
DataManager.updateRtpCoolDown(player, connection);
|
DataManager.updateRtpCoolDown(player, connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user