now add your bed spawn to the list

This commit is contained in:
mikx 2023-11-27 22:23:47 -05:00
parent b6ab82c8e1
commit f4a3c334ae
3 changed files with 22 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<groupId>ovh.mxg</groupId> <groupId>ovh.mxg</groupId>
<artifactId>CubeTP</artifactId> <artifactId>CubeTP</artifactId>
<version>SNAPSHOT</version> <version>1.3.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CubeTP</name> <name>CubeTP</name>

View File

@ -294,11 +294,17 @@ public final class CubeTP extends JavaPlugin implements Listener {
} }
public void AddAllCubes(Player player) throws SQLException { public void AddAllCubes(Player player) throws SQLException {
int slot = 9;
String uuid = player.getUniqueId().toString(); 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(); SQL.connect();
PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE uuid IS NULL"); PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE uuid IS NULL");
ResultSet rs = ps.executeQuery(); ResultSet rs = ps.executeQuery();
int slot = 9;
while(rs != null && rs.next()) { while(rs != null && rs.next()) {
String lore01 = MessageFormat.format("x{0} y{1} z{2}", rs.getDouble("x"), rs.getDouble("y"), rs.getDouble("z")); 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)); 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 { public void CubeTP(Player player, String name) throws SQLException {
SQL.connect(); if(name.equals("Spawn")){
PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE name = ?"); Location pSpawn = player.getBedSpawnLocation();
ps.setString(1, name); player.teleport(pSpawn);
ResultSet rs = ps.executeQuery(); } else {
int slot = 9; SQL.connect();
if(rs.next()) { PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE name = ?");
Location loc = new Location(player.getWorld(), rs.getDouble("x"),rs.getDouble("y"),rs.getDouble("z"), 0, 0); ps.setString(1, name);
player.teleport(loc); 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);
}
} }
} }

View File

@ -1,4 +1,4 @@
name: CubeTP name: CubeTP
version: '1.2.2' version: '1.3.0'
main: ovh.mxg.cubetp.CubeTP main: ovh.mxg.cubetp.CubeTP
api-version: '1.20' api-version: '1.20'