Skip to content

Commit 15eaed8

Browse files
committed
bukkit-api: Make PlayerSystemProviderService.get deprecated
1 parent 60c7e68 commit 15eaed8

5 files changed

Lines changed: 23 additions & 19 deletions

File tree

mimic-bukkit-api/src/main/kotlin/PlayerSystemProviderService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public abstract class PlayerSystemProviderService<T : Any>(final override val id
2626

2727
override val isEnabled: Boolean = true
2828

29+
/**
30+
* Returns new instance of [T] is given [arg] is instance of [Player].
31+
* Otherwise, throws [ClassCastException].
32+
*/
33+
@Deprecated("Use getSystem(player) instead", ReplaceWith("this.getSystem(arg)"))
2934
final override fun get(arg: Any): T = getSystem(arg as Player)
3035

3136
/** Returns new instance of [T] initialized with the given [player] object. */

mimic-bukkit/src/main/kotlin/command/ClassSystemSubcommand.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of BukkitMimic.
3-
* Copyright (C) 2020 Osip Fatkullin
4-
* Copyright (C) 2020 EndlessCode Group and contributors
3+
* Copyright (C) 2021 Osip Fatkullin
4+
* Copyright (C) 2021 EndlessCode Group and contributors
55
*
66
* BukkitMimic is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ internal class ClassSystemSubcommand(
4040
@Description("Show information about player's class system")
4141
@CommandCompletion("@players")
4242
fun info(sender: CommandSender, @Optional @Flags("other,defaultself") player: Player) {
43-
val system = systemProvider.get(player)
43+
val system = systemProvider.getSystem(player)
4444
sender.send(
4545
"&3System: &7${systemProvider.id}",
4646
"&3Classes: &7${system.classes}",
@@ -57,7 +57,7 @@ internal class ClassSystemSubcommand(
5757
@Default("all") mode: Mode,
5858
@Optional @Flags("other,defaultself") player: Player
5959
) {
60-
val system = systemProvider.get(player)
60+
val system = systemProvider.getSystem(player)
6161
val has = if (mode == Mode.ALL) {
6262
system.hasAllClasses(classes.asList())
6363
} else {

mimic-bukkit/src/main/kotlin/command/LevelSystemSubcommand.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of BukkitMimic.
3-
* Copyright (C) 2020 Osip Fatkullin
4-
* Copyright (C) 2020 EndlessCode Group and contributors
3+
* Copyright (C) 2021 Osip Fatkullin
4+
* Copyright (C) 2021 EndlessCode Group and contributors
55
*
66
* BukkitMimic is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -45,7 +45,7 @@ internal class LevelSystemSubcommand(
4545
@Description("Show information about player's level system")
4646
@CommandCompletion("@players")
4747
fun info(sender: CommandSender, @Optional @Flags("other,defaultself") player: Player) {
48-
val system = systemProvider.get(player)
48+
val system = systemProvider.getSystem(player)
4949
sender.send(
5050
"&3System: &7${systemProvider.id}",
5151
"&3Level: &7%.2f".format(system.level + system.fractionalExp),
@@ -64,8 +64,8 @@ internal class LevelSystemSubcommand(
6464
@Optional @Flags("other,defaultself") player: Player
6565
) {
6666
catchUnsupported {
67-
val system = systemProvider.get(player)
68-
@Suppress("DEPRECATION") // Allow to use exp setter
67+
val system = systemProvider.getSystem(player)
68+
@Suppress("DEPRECATION") // Allow using exp setter
6969
when (type) {
7070
ExtendedValueType.LVL -> system.level = amount.toInt()
7171
ExtendedValueType.TOTAL -> system.totalExp = amount
@@ -85,7 +85,7 @@ internal class LevelSystemSubcommand(
8585
@Optional @Flags("other,defaultself") player: Player
8686
) {
8787
catchUnsupported {
88-
val system = systemProvider.get(player)
88+
val system = systemProvider.getSystem(player)
8989
when (type) {
9090
ValueType.LVL -> system.giveLevels(amount)
9191
ValueType.POINTS -> system.giveExp(amount.toDouble())
@@ -104,7 +104,7 @@ internal class LevelSystemSubcommand(
104104
@Optional @Flags("other,defaultself") player: Player
105105
) {
106106
catchUnsupported {
107-
val system = systemProvider.get(player)
107+
val system = systemProvider.getSystem(player)
108108
when (type) {
109109
ValueType.LVL -> system.takeLevels(amount)
110110
ValueType.POINTS -> system.takeExp(amount.toDouble())
@@ -135,7 +135,7 @@ internal class LevelSystemSubcommand(
135135
@Default("lvl") type: ExtendedValueType,
136136
@Optional @Flags("other,defaultself") player: Player
137137
) {
138-
val system = systemProvider.get(player)
138+
val system = systemProvider.getSystem(player)
139139
val has = when (type) {
140140
ExtendedValueType.LVL -> system.didReachLevel(value)
141141
ExtendedValueType.POINTS -> system.hasExp(value.toDouble())

mimic-bukkit/src/test/kotlin/impl/mimic/PermissionsClassSystemTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of BukkitMimic.
3-
* Copyright (C) 2020 Osip Fatkullin
4-
* Copyright (C) 2020 EndlessCode Group and contributors
3+
* Copyright (C) 2021 Osip Fatkullin
4+
* Copyright (C) 2021 EndlessCode Group and contributors
55
*
66
* BukkitMimic is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@ import com.nhaarman.mockitokotlin2.whenever
2525
import org.bukkit.permissions.PermissionAttachmentInfo
2626
import ru.endlesscode.mimic.BukkitTestBase
2727
import ru.endlesscode.mimic.classes.ClassSystem
28-
import java.util.*
2928
import kotlin.test.BeforeTest
3029
import kotlin.test.Test
3130
import kotlin.test.assertFalse
@@ -39,7 +38,7 @@ class PermissionsClassSystemTest : BukkitTestBase() {
3938
@BeforeTest
4039
override fun setUp() {
4140
super.setUp()
42-
classSystem = PermissionsClassSystem.Provider().get(player)
41+
classSystem = PermissionsClassSystem.Provider().getSystem(player)
4342
}
4443

4544
@Test

mimic-bukkit/src/test/kotlin/impl/vanilla/MinecraftLevelSystemTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of BukkitMimic.
3-
* Copyright (C) 2020 Osip Fatkullin
4-
* Copyright (C) 2020 EndlessCode Group and contributors
3+
* Copyright (C) 2021 Osip Fatkullin
4+
* Copyright (C) 2021 EndlessCode Group and contributors
55
*
66
* BukkitMimic is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ class MinecraftLevelSystemTest : BukkitTestBase() {
3838
@BeforeTest
3939
override fun setUp() {
4040
super.setUp()
41-
levelSystem = MinecraftLevelSystem.Provider().get(player)
41+
levelSystem = MinecraftLevelSystem.Provider().getSystem(player)
4242
}
4343

4444
@Test

0 commit comments

Comments
 (0)