Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
846 B
32 lines
846 B
4 years ago
|
package org.openrs2.archive.name
|
||
4 years ago
|
|
||
4 years ago
|
import org.openrs2.db.Database
|
||
|
import org.openrs2.util.krHashCode
|
||
4 years ago
|
import javax.inject.Inject
|
||
|
import javax.inject.Singleton
|
||
|
|
||
|
@Singleton
|
||
|
public class NameImporter @Inject constructor(
|
||
|
private val database: Database
|
||
|
) {
|
||
|
public suspend fun import(names: Iterable<String>) {
|
||
|
database.execute { connection ->
|
||
|
connection.prepareStatement(
|
||
|
"""
|
||
|
INSERT INTO names (hash, name)
|
||
|
VALUES (?, ?)
|
||
|
ON CONFLICT DO NOTHING
|
||
|
""".trimIndent()
|
||
|
).use { stmt ->
|
||
|
for (name in names) {
|
||
|
stmt.setInt(1, name.krHashCode())
|
||
|
stmt.setString(2, name)
|
||
|
stmt.addBatch()
|
||
|
}
|
||
|
|
||
|
stmt.executeBatch()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|