Per-world Creeper settings complete
- Added per-world Block Damage settings - Added per-world Entity Damage settings - Added creeper_settings database support - Added world-specific Creeper menus - Added automatic world registration/default inheritance - Split Creeper listeners - Updated Creeper behavior to use world settings - Removed obsolete global Creeper indicators - Adopted logger-based error reporting standard
This commit is contained in:
1 parent
ebf030b192
commit
73a0ef8ae6
23 files changed
+1203
-73
No files matched your search
@@ -0,0 +1,142 @@
|
||||
package com.rsscripting.serveradmin.dao;
|
||||
|
||||
import com.rsscripting.serveradmin.database.DatabaseManager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class KeepInventoryDAO {
|
||||
|
||||
private final DatabaseManager databaseManager;
|
||||
|
||||
public KeepInventoryDAO(
|
||||
DatabaseManager databaseManager
|
||||
) {
|
||||
|
||||
this.databaseManager = databaseManager;
|
||||
|
||||
}
|
||||
|
||||
public boolean getWorldSetting(
|
||||
String worldName
|
||||
) throws SQLException {
|
||||
|
||||
Connection connection =
|
||||
databaseManager.getConnection();
|
||||
|
||||
try (PreparedStatement statement =
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
SELECT enabled
|
||||
FROM keep_inventory
|
||||
WHERE world_name = ?
|
||||
"""
|
||||
)) {
|
||||
|
||||
statement.setString(
|
||||
1,
|
||||
worldName
|
||||
);
|
||||
|
||||
try (ResultSet rs =
|
||||
statement.executeQuery()) {
|
||||
|
||||
if (rs.next()) {
|
||||
|
||||
return rs.getInt(
|
||||
"enabled"
|
||||
) == 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void setWorldSetting(
|
||||
String worldName,
|
||||
boolean enabled
|
||||
) throws SQLException {
|
||||
|
||||
Connection connection =
|
||||
databaseManager.getConnection();
|
||||
|
||||
try (PreparedStatement statement =
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
INSERT OR REPLACE INTO keep_inventory
|
||||
(
|
||||
world_name,
|
||||
enabled
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
?,
|
||||
?
|
||||
)
|
||||
"""
|
||||
)) {
|
||||
|
||||
statement.setString(
|
||||
1,
|
||||
worldName
|
||||
);
|
||||
|
||||
statement.setInt(
|
||||
2,
|
||||
enabled ? 1 : 0
|
||||
);
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ensureWorldExists(
|
||||
String worldName,
|
||||
boolean defaultValue
|
||||
) throws SQLException {
|
||||
|
||||
Connection connection =
|
||||
databaseManager.getConnection();
|
||||
|
||||
try (PreparedStatement statement =
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
INSERT OR IGNORE INTO keep_inventory
|
||||
(
|
||||
world_name,
|
||||
enabled
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
?,
|
||||
?
|
||||
)
|
||||
"""
|
||||
)) {
|
||||
|
||||
statement.setString(
|
||||
1,
|
||||
worldName
|
||||
);
|
||||
|
||||
statement.setInt(
|
||||
2,
|
||||
defaultValue ? 1 : 0
|
||||
);
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user