More refactoring

This commit is contained in:
BuildTools authored and WiIIiam278 committed 2021-05-30 23:13:02 +01:00
1 parent b3fd814c0c
commit f3504a20a4
37 files changed
+1379 -1297

No files matched your search

@@ -0,0 +1,34 @@
package me.william278.huskhomes2.commands;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.MessageManager;
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 TpHereCommand extends CommandBase {
private static final HuskHomes plugin = HuskHomes.getInstance();
@Override
protected void onCommand(Player p, Command command, String label, String[] args) {
if (args.length == 1) {
String targetPlayer = args[0];
Connection connection = HuskHomes.getConnection();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
TeleportManager.teleportHere(p, targetPlayer, connection);
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred using /tphere");
}
});
} else {
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
}
}
}