Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void setSpawn(Player p) {
- Location loc = p.getLocation();
- double x, y, z;
- float pitch, yaw;
- x = loc.getX();
- y = loc.getY();
- z = loc.getZ();
- pitch = loc.getPitch();
- yaw = loc.getYaw();
- String w = loc.getWorld().getName();
- if (!getMySQL()) {
- try {
- PreparedStatement ps = sql.getConnection()
- .prepareStatement("INSERT INTO kw_spawn (mundo, x, y, z, pitch, yaw) VALUES(?,?,?,?,?,?);");
- ps.setString(1, w);
- ps.setString(2, Double.toString(x));
- ps.setString(3, Double.toString(y));
- ps.setString(4, Double.toString(z));
- ps.setString(5, Float.toString(pitch));
- ps.setString(6, Float.toString(yaw));
- ps.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- } else {
- try {
- PreparedStatement ps = sql.getConnection().prepareStatement("SELECT * FROM kw_spawn");
- ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- ps = sql.getConnection().prepareStatement("UPDATE kw_spawn");
- ps.setString(1, w);
- ps.setString(2, Double.toString(x));
- ps.setString(3, Double.toString(y));
- ps.setString(4, Double.toString(z));
- ps.setString(5, Float.toString(pitch));
- ps.setString(6, Float.toString(yaw));
- ps.executeUpdate();
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- p.sendMessage(KwMetodos.getReplaced("Setado"));
- }
Advertisement
Add Comment
Please, Sign In to add comment