UI Tweaks/Private Cube/Fixed the left click bug
This commit is contained in:
parent
cd63a4534c
commit
e0627b5eee
|
@ -50,6 +50,7 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
||||||
Location clickedCubeLoc;
|
Location clickedCubeLoc;
|
||||||
Block clickedBlock;
|
Block clickedBlock;
|
||||||
String curCubeName = "";
|
String curCubeName = "";
|
||||||
|
boolean curCubePrivate = false;
|
||||||
double curCubeX = 0;
|
double curCubeX = 0;
|
||||||
double curCubeY = 0;
|
double curCubeY = 0;
|
||||||
double curCubeZ = 0;
|
double curCubeZ = 0;
|
||||||
|
@ -93,6 +94,11 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
||||||
Sign sign = (Sign) state;
|
Sign sign = (Sign) state;
|
||||||
SignSide sside = sign.getSide(Side.FRONT);
|
SignSide sside = sign.getSide(Side.FRONT);
|
||||||
curCubeName = sside.getLine(0);
|
curCubeName = sside.getLine(0);
|
||||||
|
if(!sside.getLine(1).isEmpty()){
|
||||||
|
curCubePrivate = true;
|
||||||
|
} else {
|
||||||
|
curCubePrivate = false;
|
||||||
|
}
|
||||||
curCubeX = clickedBlock.getLocation().getBlockX();
|
curCubeX = clickedBlock.getLocation().getBlockX();
|
||||||
curCubeY = clickedBlock.getLocation().getBlockY();
|
curCubeY = clickedBlock.getLocation().getBlockY();
|
||||||
curCubeZ = clickedBlock.getLocation().getBlockZ();
|
curCubeZ = clickedBlock.getLocation().getBlockZ();
|
||||||
|
@ -113,9 +119,8 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(final InventoryClickEvent e) throws SQLException {
|
public void onInventoryClick(final InventoryClickEvent e) throws SQLException {
|
||||||
if (!e.getInventory().equals(inv)) return;
|
|
||||||
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
if (!e.isLeftClick()) return;
|
||||||
|
|
||||||
final ItemStack clickedItem = e.getCurrentItem();
|
final ItemStack clickedItem = e.getCurrentItem();
|
||||||
|
|
||||||
|
@ -129,7 +134,11 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
||||||
if(SQL.CheckCubeNameExists(curCubeName)){
|
if(SQL.CheckCubeNameExists(curCubeName)){
|
||||||
p.sendMessage(MessageFormat.format("§bLe cube {0} existe déjà. Changez le nom.", curCubeName));
|
p.sendMessage(MessageFormat.format("§bLe cube {0} existe déjà. Changez le nom.", curCubeName));
|
||||||
} else {
|
} else {
|
||||||
SQL.AddCube(curCubeName, curCubeX, curCubeY, curCubeZ);
|
if(curCubePrivate){
|
||||||
|
SQL.AddCube(curCubeName, curCubeX, curCubeY, curCubeZ, p.getUniqueId().toString());
|
||||||
|
} else {
|
||||||
|
SQL.AddCube(curCubeName, curCubeX, curCubeY, curCubeZ, null);
|
||||||
|
}
|
||||||
p.sendMessage(MessageFormat.format("§bLe cube {0} a été ajouté.", curCubeName));
|
p.sendMessage(MessageFormat.format("§bLe cube {0} a été ajouté.", curCubeName));
|
||||||
ShowUI(p);
|
ShowUI(p);
|
||||||
}
|
}
|
||||||
|
@ -246,42 +255,51 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
||||||
SignSide sside = sign.getSide(Side.FRONT);
|
SignSide sside = sign.getSide(Side.FRONT);
|
||||||
String lore01 = MessageFormat.format("{0}", sside.getLine(0));
|
String lore01 = MessageFormat.format("{0}", sside.getLine(0));
|
||||||
String lore02 = MessageFormat.format("x{0} y{1} z{2}", clickedBlock.getLocation().getBlockX(), clickedBlock.getLocation().getBlockY(), clickedBlock.getLocation().getBlockZ());
|
String lore02 = MessageFormat.format("x{0} y{1} z{2}", clickedBlock.getLocation().getBlockX(), clickedBlock.getLocation().getBlockY(), clickedBlock.getLocation().getBlockZ());
|
||||||
inv.setItem(0,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(0,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(1,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(1,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(2,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(2,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(3,createGuiItem(Material.BOOK, "§bEnregistrer", lore01, lore02));
|
inv.setItem(3,createGuiItem(Material.CYAN_WOOL, "§bEnregistrer", lore01, lore02));
|
||||||
inv.setItem(4,createGuiItem(Material.ENCHANTED_BOOK, "Tome de portail"));
|
inv.setItem(4,createGuiItem(Material.CYAN_WOOL, "§bTome de portail"));
|
||||||
inv.setItem(5,createGuiItem(Material.TNT, "§bRetirer", "§aRetirer de la liste de TP."));
|
inv.setItem(5,createGuiItem(Material.CYAN_WOOL, "§bRetirer"));
|
||||||
inv.setItem(6,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(6,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(7,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(7,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(8,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(8,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
AddAllCubes(player);
|
AddAllCubes(player);
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowUIPortal(Player player) throws SQLException {
|
public void ShowUIPortal(Player player) throws SQLException {
|
||||||
inv = Bukkit.createInventory(null, 45, "CubeTP");
|
inv = Bukkit.createInventory(null, 45, "CubeTP");
|
||||||
inv.setItem(0,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(0,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(1,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(1,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(2,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(2,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(3,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(3,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(4,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(4,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(5,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(5,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(6,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(6,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(7,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(7,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
inv.setItem(8,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
inv.setItem(8,createGuiItem(Material.BLACK_WOOL, " "));
|
||||||
AddAllCubes(player);
|
AddAllCubes(player);
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddAllCubes(Player player) throws SQLException {
|
public void AddAllCubes(Player player) throws SQLException {
|
||||||
|
String uuid = player.getUniqueId().toString();
|
||||||
SQL.connect();
|
SQL.connect();
|
||||||
PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp");
|
PreparedStatement ps = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE uuid IS NULL");
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
int slot = 9;
|
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.SPYGLASS, rs.getString("name"), lore01));
|
inv.setItem(slot,createGuiItem(Material.GREEN_WOOL, rs.getString("name"), lore01));
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
PreparedStatement psp = SQL.getConnection().prepareStatement("SELECT * FROM cubetp WHERE uuid IS NOT NULL AND uuid = ?");
|
||||||
|
psp.setString(1, uuid);
|
||||||
|
ResultSet rsp = psp.executeQuery();
|
||||||
|
while(rsp != null && rsp.next()) {
|
||||||
|
String lore01 = MessageFormat.format("x{0} y{1} z{2}", rsp.getDouble("x"), rsp.getDouble("y"), rsp.getDouble("z"));
|
||||||
|
inv.setItem(slot,createGuiItem(Material.ORANGE_WOOL, rsp.getString("name"), lore01));
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,18 @@ public class SQL {
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddCube(String name, double x, double y, double z) throws SQLException {
|
public static void AddCube(String name, double x, double y, double z, String uuid) throws SQLException {
|
||||||
connect();
|
connect();
|
||||||
PreparedStatement ps = getConnection().prepareStatement("INSERT IGNORE INTO cubetp (name,x,y,z) VALUES (?,?,?,?)");
|
PreparedStatement ps = getConnection().prepareStatement("INSERT IGNORE INTO cubetp (name,x,y,z,uuid) VALUES (?,?,?,?,?)");
|
||||||
ps.setString(1, name);
|
ps.setString(1, name);
|
||||||
ps.setDouble(2, x);
|
ps.setDouble(2, x);
|
||||||
ps.setDouble(3, y);
|
ps.setDouble(3, y);
|
||||||
ps.setDouble(4, z);
|
ps.setDouble(4, z);
|
||||||
|
if(uuid != null){
|
||||||
|
ps.setString(5, uuid);
|
||||||
|
} else {
|
||||||
|
ps.setString(5, null);
|
||||||
|
}
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: CubeTP
|
name: CubeTP
|
||||||
version: '1.0-SNAPSHOT'
|
version: '1.1.0'
|
||||||
main: ovh.mxg.cubetp.CubeTP
|
main: ovh.mxg.cubetp.CubeTP
|
||||||
api-version: '1.20'
|
api-version: '1.20'
|
||||||
|
|
Loading…
Reference in New Issue