forked from SuperRicky14/TpaPlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Refactor database manager to json manager
* Because a SQLite package resulted in too large jar package, I decided to abandon SQLite and use JSON to store player data * Add interface DataService for possible future expansions
- Loading branch information
1 parent
3ad8121
commit d86991d
Showing
19 changed files
with
184 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/net/superricky/tpaplusplus/database/DataService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.superricky.tpaplusplus.database | ||
|
||
import net.minecraft.server.network.ServerPlayerEntity | ||
import net.superricky.tpaplusplus.utility.LevelBoundVec3 | ||
import java.util.* | ||
|
||
interface DataService { | ||
fun initDataService() | ||
fun getPlayerData(player: ServerPlayerEntity): PlayerData | ||
fun addBlockPlayer(uuid: UUID, blockPlayer: UUID): Boolean | ||
fun removeBlockPlayer(uuid: UUID, blockPlayer: UUID): Boolean | ||
fun playerSwitchBlock(uuid: UUID): Boolean | ||
fun playerSwitchBlock(uuid: UUID, toggle: Boolean): Boolean | ||
fun insertPlayer(uuid: UUID) | ||
fun insertDeath(uuid: UUID, pos: LevelBoundVec3) | ||
fun savePlayerData() | ||
} |
9 changes: 0 additions & 9 deletions
9
src/main/kotlin/net/superricky/tpaplusplus/database/DatabaseCacheService.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/kotlin/net/superricky/tpaplusplus/database/DatabaseConst.kt
This file was deleted.
Oops, something went wrong.
164 changes: 0 additions & 164 deletions
164
src/main/kotlin/net/superricky/tpaplusplus/database/DatabaseManager.kt
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/net/superricky/tpaplusplus/database/DeathPos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.superricky.tpaplusplus.database | ||
|
||
data class DeathPos( | ||
var x: Double = 0.0, | ||
var y: Double = 0.0, | ||
var z: Double = 0.0, | ||
var world: String = "", | ||
var backed: Boolean = true | ||
) |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/database/PlayerData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.superricky.tpaplusplus.database | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import java.util.* | ||
|
||
class PlayerData( | ||
@SerializedName("block_players") | ||
val blockPlayers: MutableSet<UUID> = Collections.synchronizedSet(HashSet()), | ||
@SerializedName("last_death_pos") | ||
val lastDeathPos: DeathPos = DeathPos(), | ||
@SerializedName("toggle") | ||
var toggle: Boolean = false | ||
) |
Oops, something went wrong.