mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
More refactoring
This commit is contained in:
1 parent
b3fd814c0c
commit
f3504a20a4
37 files changed
+1379
-1297
No files matched your search
@@ -4,32 +4,45 @@ import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.data.DataManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SpawnCommand extends CommandBase {
|
||||
|
||||
private final static HuskHomes plugin = HuskHomes.getInstance();
|
||||
|
||||
@Override
|
||||
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.getSettings().doSpawnCommand()) {
|
||||
String spawnWarpName = HuskHomes.getSettings().getSpawnWarpName();
|
||||
Connection connection = HuskHomes.getConnection();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
try {
|
||||
// Cross server spawn teleport
|
||||
if (HuskHomes.getSettings().doCrossServerSpawn()) {
|
||||
if (DataManager.warpExists(spawnWarpName, connection)) {
|
||||
TeleportManager.queueTimedTeleport(p, DataManager.getWarp(spawnWarpName, connection), connection);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Cross server spawn teleport
|
||||
if (HuskHomes.getSettings().doCrossServerSpawn()) {
|
||||
if (DataManager.warpExists(spawnWarpName)) {
|
||||
TeleportManager.queueTimedTeleport(p, DataManager.getWarp(spawnWarpName));
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||
// Server-based spawn teleport
|
||||
if (TeleportManager.getSpawnLocation() != null) {
|
||||
TeleportManager.queueTimedTeleport(p, TeleportManager.getSpawnLocation(), connection);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "An exception occurred returning back to spawn");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Server-based spawn teleport
|
||||
if (TeleportManager.getSpawnLocation() != null) {
|
||||
TeleportManager.queueTimedTeleport(p, TeleportManager.getSpawnLocation());
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_command_disabled");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user