diff --git a/pom.xml b/pom.xml index 78797e1..4a2a539 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ovh.mxg CubeTP - SNAPSHOT + 1.3.0 jar CubeTP diff --git a/src/main/java/ovh/mxg/cubetp/CubeTP.java b/src/main/java/ovh/mxg/cubetp/CubeTP.java index 954dc57..153a111 100644 --- a/src/main/java/ovh/mxg/cubetp/CubeTP.java +++ b/src/main/java/ovh/mxg/cubetp/CubeTP.java @@ -294,11 +294,17 @@ public final class CubeTP extends JavaPlugin implements Listener { } public void AddAllCubes(Player player) throws SQLException { + int slot = 9; String uuid = player.getUniqueId().toString(); + if(player.getBedSpawnLocation() != null){ + slot = 10; + Location spawnLoc = player.getBedSpawnLocation(); + String loreSp = MessageFormat.format("x{0} y{1} z{2}", spawnLoc.getBlockX(), spawnLoc.getBlockY(), spawnLoc.getBlockZ()); + inv.setItem(9,createGuiItem(Material.WHITE_WOOL, "Spawn", loreSp)); + } SQL.connect(); PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE uuid IS NULL"); ResultSet rs = ps.executeQuery(); - int slot = 9; while(rs != null && rs.next()) { String lore01 = MessageFormat.format("x{0} y{1} z{2}", rs.getDouble("x"), rs.getDouble("y"), rs.getDouble("z")); inv.setItem(slot,createGuiItem(Material.GREEN_WOOL, rs.getString("name"), lore01)); @@ -315,14 +321,19 @@ public final class CubeTP extends JavaPlugin implements Listener { } public void CubeTP(Player player, String name) throws SQLException { - SQL.connect(); - PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE name = ?"); - ps.setString(1, name); - ResultSet rs = ps.executeQuery(); - int slot = 9; - if(rs.next()) { - Location loc = new Location(player.getWorld(), rs.getDouble("x"),rs.getDouble("y"),rs.getDouble("z"), 0, 0); - player.teleport(loc); + if(name.equals("Spawn")){ + Location pSpawn = player.getBedSpawnLocation(); + player.teleport(pSpawn); + } else { + SQL.connect(); + PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE name = ?"); + ps.setString(1, name); + ResultSet rs = ps.executeQuery(); + int slot = 9; + if(rs.next()) { + Location loc = new Location(player.getWorld(), rs.getDouble("x"),rs.getDouble("y"),rs.getDouble("z"), 0, 0); + player.teleport(loc); + } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 09bad88..631ac31 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ name: CubeTP -version: '1.2.2' +version: '1.3.0' main: ovh.mxg.cubetp.CubeTP api-version: '1.20'