Remove legacy modules, add language & scoreboard
Large refactor removing many legacy subsystems (abilities, kit system, database repos, recraft, world manager, extensive config classes, lunar/luckperms integrations and various listeners/commands). Introduces a lightweight LanguageManager, AntiRunningManager, ScoreboardManager, ConnectListener and a SoupListener; simplifies the main SpeedHG plugin to initialize these components and register the connection listener. Build changes: update Gradle wrapper to 8.10, remove paperweight and several external dependencies, add fr.mrmicky:fastboard and simplify shadowJar/build task configuration. Adds default language resource (languages/en_US.yml) and updates plugin/config resources. Purpose: simplify and decouple the plugin, reduce dependency surface and prepare for a leaner, modular rewrite.
This commit is contained in:
@@ -1,125 +0,0 @@
|
||||
package club.mcscrims.speedhg.database
|
||||
|
||||
import club.mcscrims.core.database.mongodb.MongoConnection
|
||||
import club.mcscrims.core.database.mongodb.MongoRepository
|
||||
import com.mongodb.client.model.Filters
|
||||
import com.mongodb.client.model.Updates
|
||||
import org.bson.codecs.pojo.annotations.BsonId
|
||||
import org.bson.codecs.pojo.annotations.BsonProperty
|
||||
import org.bson.conversions.Bson
|
||||
import org.bson.types.ObjectId
|
||||
import org.bukkit.Bukkit
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* MongoDB-Entity für einen Spieler
|
||||
*/
|
||||
data class KitPlayer(
|
||||
@BsonId
|
||||
val id: ObjectId = ObjectId(),
|
||||
|
||||
@BsonProperty
|
||||
val uuid: String,
|
||||
|
||||
@BsonProperty
|
||||
val isAlive: Boolean,
|
||||
|
||||
@BsonProperty
|
||||
val unlockedKits: List<String>,
|
||||
|
||||
@BsonProperty
|
||||
val server: String
|
||||
)
|
||||
|
||||
/**
|
||||
* MongoDB-Repository für Spieler-Daten
|
||||
*/
|
||||
class PlayerRepository(
|
||||
connection: MongoConnection
|
||||
): MongoRepository<KitPlayer>( connection, "kit_players", KitPlayer::class.java ) {
|
||||
|
||||
override fun getId(
|
||||
entity: KitPlayer
|
||||
): ObjectId
|
||||
{
|
||||
return entity.id
|
||||
}
|
||||
|
||||
override fun setId(
|
||||
entity: KitPlayer,
|
||||
id: ObjectId
|
||||
): KitPlayer
|
||||
{
|
||||
return entity.copy( id = id )
|
||||
}
|
||||
|
||||
override fun entityToUpdateDocument(
|
||||
entity: KitPlayer
|
||||
): Bson = Updates.combine(
|
||||
Updates.set("isAlive", entity.isAlive),
|
||||
Updates.set("unlockedKits", entity.unlockedKits),
|
||||
Updates.set("server", entity.server)
|
||||
)
|
||||
|
||||
/**
|
||||
* Findet einen Spieler anhand seiner UUID
|
||||
*/
|
||||
suspend fun findByUuid(
|
||||
uuid: UUID
|
||||
): KitPlayer?
|
||||
{
|
||||
val filter = Filters.eq("uuid", uuid.toString())
|
||||
return findFirst(filter)
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet alle lebenden Spieler für einen Server
|
||||
*/
|
||||
suspend fun findAlivePlayers(
|
||||
server: String
|
||||
): List<KitPlayer>
|
||||
{
|
||||
val filter = Filters.and(
|
||||
Filters.eq("server", server),
|
||||
Filters.eq("isAlive", true)
|
||||
)
|
||||
return find(filter, Bukkit.getMaxPlayers())
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert den Alive-Status eines Spielers
|
||||
*/
|
||||
suspend fun updateAliveStatus(
|
||||
uuid: UUID,
|
||||
isAlive: Boolean
|
||||
) {
|
||||
val filter = Filters.eq("uuid", uuid.toString())
|
||||
val update = Updates.set("isAlive", isAlive)
|
||||
connection.updateOne(collectionName, filter, update)
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert den Server eines Spielers
|
||||
*/
|
||||
suspend fun updateServer(
|
||||
uuid: UUID,
|
||||
server: String
|
||||
) {
|
||||
val filter = Filters.eq("uuid", uuid.toString())
|
||||
val update = Updates.set("server", server)
|
||||
connection.updateOne(collectionName, filter, update)
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert die freigeschalteten Kits eines Spielers
|
||||
*/
|
||||
suspend fun updateUnlockedKits(
|
||||
uuid: UUID,
|
||||
unlockedKits: List<String>
|
||||
) {
|
||||
val filter = Filters.eq("uuid", uuid.toString())
|
||||
val update = Updates.set("unlockedKits", unlockedKits)
|
||||
connection.updateOne(collectionName, filter, update)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
package club.mcscrims.speedhg.database
|
||||
|
||||
import club.mcscrims.core.database.mongodb.MongoConnection
|
||||
import club.mcscrims.core.database.mongodb.MongoRepository
|
||||
import com.mongodb.client.model.Aggregates
|
||||
import com.mongodb.client.model.Filters
|
||||
import com.mongodb.client.model.Sorts
|
||||
import com.mongodb.client.model.Updates
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import org.bson.codecs.pojo.annotations.BsonId
|
||||
import org.bson.codecs.pojo.annotations.BsonProperty
|
||||
import org.bson.conversions.Bson
|
||||
import org.bson.types.ObjectId
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* MongoDB-Entity für die Stats von einem Spieler
|
||||
*/
|
||||
data class PlayerStats(
|
||||
@BsonId
|
||||
val id: ObjectId? = null,
|
||||
|
||||
@BsonProperty("uuid")
|
||||
val uuid: String,
|
||||
|
||||
@BsonProperty("kills")
|
||||
val kills: Int,
|
||||
|
||||
@BsonProperty("deaths")
|
||||
val deaths: Int,
|
||||
|
||||
@BsonProperty("wins")
|
||||
val wins: Int,
|
||||
|
||||
@BsonProperty("gamesPlayed")
|
||||
val gamesPlayed: Int,
|
||||
|
||||
@BsonProperty("unathleticIndex")
|
||||
val unathleticIndex: Double,
|
||||
|
||||
@BsonProperty("ironFarmed")
|
||||
val ironFarmed: Double
|
||||
)
|
||||
|
||||
/**
|
||||
* MongoDB-Repository für Stats-Daten
|
||||
*/
|
||||
class StatsRepository(
|
||||
connection: MongoConnection
|
||||
): MongoRepository<PlayerStats>( connection, "player_stats", PlayerStats::class.java ) {
|
||||
|
||||
override fun getId(
|
||||
entity: PlayerStats
|
||||
): ObjectId?
|
||||
{
|
||||
return entity.id
|
||||
}
|
||||
|
||||
override fun setId(
|
||||
entity: PlayerStats,
|
||||
id: ObjectId
|
||||
): PlayerStats
|
||||
{
|
||||
return entity.copy( id = id )
|
||||
}
|
||||
|
||||
override fun entityToUpdateDocument(
|
||||
entity: PlayerStats
|
||||
): Bson = Updates.combine(
|
||||
Updates.set( "kills", entity.kills ),
|
||||
Updates.set( "deaths", entity.deaths ),
|
||||
Updates.set( "wins", entity.wins ),
|
||||
Updates.set( "gamesPlayed", entity.gamesPlayed ),
|
||||
Updates.set( "unathleticIndex", entity.unathleticIndex ),
|
||||
Updates.set( "ironFarmed", entity.ironFarmed )
|
||||
)
|
||||
|
||||
/**
|
||||
* Findet einen Spieler anhand seiner UUID
|
||||
*/
|
||||
suspend fun findByUuid(
|
||||
uuid: UUID
|
||||
): PlayerStats?
|
||||
{
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
return findFirst( filter )
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet Top-Spieler nach Kills
|
||||
*/
|
||||
suspend fun findTopPlayersByKills(
|
||||
limit: Int = 10
|
||||
): List<PlayerStats>
|
||||
{
|
||||
return connection.getCollection( collectionName ).aggregate(listOf(
|
||||
Aggregates.sort(Sorts.descending( "kills" )),
|
||||
Aggregates.limit( limit )
|
||||
), PlayerStats::class.java ).toList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet Top-Spieler nach Deaths
|
||||
*/
|
||||
suspend fun findTopPlayersByDeaths(
|
||||
limit: Int = 10
|
||||
): List<PlayerStats>
|
||||
{
|
||||
return connection.getCollection( collectionName ).aggregate(listOf(
|
||||
Aggregates.sort(Sorts.ascending( "deaths" )),
|
||||
Aggregates.limit( limit )
|
||||
), PlayerStats::class.java ).toList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet Top-Spieler nach Wins
|
||||
*/
|
||||
suspend fun findTopPlayersByWins(
|
||||
limit: Int = 10
|
||||
): List<PlayerStats>
|
||||
{
|
||||
return connection.getCollection( collectionName ).aggregate(listOf(
|
||||
Aggregates.sort(Sorts.descending( "wins" )),
|
||||
Aggregates.limit( limit )
|
||||
), PlayerStats::class.java ).toList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Kills zu einem Spieler hinzu
|
||||
*/
|
||||
suspend fun addKills(
|
||||
uuid: UUID,
|
||||
kills: Int
|
||||
) {
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
val update = Updates.inc( "kills", kills )
|
||||
connection.updateOne( collectionName, filter, update )
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Deaths zu einem Spieler hinzu
|
||||
*/
|
||||
suspend fun addDeaths(
|
||||
uuid: UUID,
|
||||
deaths: Int
|
||||
) {
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
val update = Updates.inc( "deaths", deaths )
|
||||
connection.updateOne( collectionName, filter, update )
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Wins zu einem Spieler hinzu
|
||||
*/
|
||||
suspend fun addWins(
|
||||
uuid: UUID,
|
||||
wins: Int
|
||||
) {
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
val update = Updates.inc( "wins", wins )
|
||||
connection.updateOne( collectionName, filter, update )
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Spiele zu einem Spieler hinzu
|
||||
*/
|
||||
suspend fun addGames(
|
||||
uuid: UUID,
|
||||
gamesPlayed: Int
|
||||
) {
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
val update = Updates.inc( "gamesPlayed", gamesPlayed )
|
||||
connection.updateOne( collectionName, filter, update )
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Unathletic-Index zu einem Spieler hinzu
|
||||
*/
|
||||
suspend fun addUnathleticIndex(
|
||||
uuid: UUID,
|
||||
unathleticIndex: Double
|
||||
) {
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
val update = Updates.inc( "unathleticIndex", unathleticIndex )
|
||||
connection.updateOne( collectionName, filter, update )
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Eisen zu einem Spieler hinzu
|
||||
*/
|
||||
suspend fun addIronFarmed(
|
||||
uuid: UUID,
|
||||
ironFarmed: Double
|
||||
) {
|
||||
val filter = Filters.eq( "uuid", uuid.toString() )
|
||||
val update = Updates.inc( "ironFarmed", ironFarmed )
|
||||
connection.updateOne( collectionName, filter, update )
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user