Added experimental tp ignore support

This commit is contained in:
BuildTools committed 2021-07-08 02:11:50 +03:00
1 parent b186d4813d
commit c6ad5ece5c
15 files changed
+185 -49

No files matched your search

@@ -120,6 +120,27 @@ public class DataManager {
return null;
}
// Return if the player is ignoring teleport requests
public static Boolean getPlayerIgnoringRequests(Player p, Connection connection) throws SQLException {
PreparedStatement ps;
ResultSet rs;
ps = connection.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `user_uuid`=?;");
ps.setString(1, p.getUniqueId().toString());
rs = ps.executeQuery();
if (rs != null) {
if (rs.next()) {
final boolean isIgnoringRequests = rs.getBoolean("is_ignoring_requests");
ps.close();
return isIgnoringRequests;
}
} else {
Bukkit.getLogger().severe("Failed to retrieve if player was ignoring teleport requests");
}
ps.close();
return null;
}
// Return a player's UUID
public static String getPlayerUUID(int playerID, Connection connection) throws SQLException {
return getPlayerString(playerID, "user_uuid", connection);
@@ -373,7 +394,7 @@ public class DataManager {
ps.close();
}
public static void setPlayerTeleportingData(UUID uuid, boolean value, Connection connection) throws SQLException {
private static void setPlayerTeleportingData(UUID uuid, boolean value, Connection connection) throws SQLException {
PreparedStatement ps;
ps = connection.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `is_teleporting`=? WHERE `user_uuid`=?;");
ps.setBoolean(1, value);
@@ -382,6 +403,15 @@ public class DataManager {
ps.close();
}
private static void setPlayerIgnoringRequestsData(UUID uuid, boolean value, Connection connection) throws SQLException {
PreparedStatement ps;
ps = connection.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `is_ignoring_requests`=? WHERE `user_uuid`=?;");
ps.setBoolean(1, value);
ps.setString(2, uuid.toString());
ps.executeUpdate();
ps.close();
}
public static void setPlayerHomeSlots(UUID uuid, int newValue, Connection connection) throws SQLException {
PreparedStatement ps;
ps = connection.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `home_slots`=? WHERE `user_uuid`=?;");
@@ -735,6 +765,10 @@ public class DataManager {
setPlayerTeleportingData(p.getUniqueId(), value, connection);
}
public static void setPlayerIgnoringRequests(Player p, boolean value, Connection connection) throws SQLException {
setPlayerIgnoringRequestsData(p.getUniqueId(), value, connection);
}
public static void updateRtpCooldown(Player p, Connection connection) throws SQLException {
long currentTime = Instant.now().getEpochSecond();
int newCoolDownTime = (int) currentTime + (60 * HuskHomes.getSettings().getRtpCoolDown());
@@ -33,6 +33,7 @@ public class MySQL extends Database {
"`is_teleporting` boolean NOT NULL DEFAULT 0," +
"`dest_location_id` integer NULL," +
"`last_location_id` integer NULL," +
"`is_ignoring_requests` boolean NOT NULL DEFAULT 0," +
"PRIMARY KEY (`player_id`)," +
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
@@ -35,6 +35,7 @@ public class SQLite extends Database {
"`is_teleporting` boolean NOT NULL DEFAULT 0," +
"`dest_location_id` integer NULL," +
"`last_location_id` integer NULL," +
"`is_ignoring_requests` boolean NOT NULL DEFAULT 0," +
"PRIMARY KEY (`player_id`)," +
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +