Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit a19c788

Browse files
committed
cleanup some warnings
1 parent 7fcfa6a commit a19c788

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+346
-425
lines changed

src/jvmMain/kotlin/OfflinePlayer.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,24 @@ class OfflinePlayer(override var uuid: UUID) :
4848
get() = Server.instance.bannedPlayers.isBanned(this.getEntityName())
4949
set(value) {
5050
if (value) {
51-
Server.instance.bannedPlayers.addBan(this.getEntityName()!!, null, null, null)
51+
Server.instance.bannedPlayers.addBan(this.getEntityName(), null, null, null)
5252
} else {
53-
Server.instance.bannedPlayers.remove(this.getEntityName()!!)
53+
Server.instance.bannedPlayers.remove(this.getEntityName())
5454
}
5555
}
5656

5757
override var isWhitelisted: Boolean
58-
get() = Server.instance.isWhitelisted(getEntityName()!!.lowercase())
58+
get() = Server.instance.isWhitelisted(getEntityName().lowercase())
5959
set(value) {
6060
if (value) {
61-
Server.instance.addWhitelist(getEntityName()!!.lowercase())
61+
Server.instance.addWhitelist(getEntityName().lowercase())
6262
} else {
63-
Server.instance.removeWhitelist(getEntityName()!!.lowercase())
63+
Server.instance.removeWhitelist(getEntityName().lowercase())
6464
}
6565
}
6666

6767
override val player: Player?
68-
get() = if (getEntityName() != null) Server.instance.getPlayerExact(getEntityName()!!) else null
68+
get() = Server.instance.getPlayerExact(getEntityName())
6969

7070
override val firstPlayed: Long
7171
get() = namedTag.getLong("firstPlayed")

src/jvmMain/kotlin/Player.kt

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,6 @@ open class Player(
11161116

11171117
fun checkNearEntities() {
11181118
for (entity in level!!.getNearbyEntities(boundingBox.grow(1.0, 0.5, 1.0), this)) {
1119-
if (entity == null) continue
11201119
entity.scheduleUpdate()
11211120

11221121
if (!entity.isAlive() || !this.isAlive()) {
@@ -1485,8 +1484,8 @@ open class Player(
14851484

14861485
adventureSettings.init(nbt)
14871486

1488-
val level: Level?
1489-
if (Server.instance.getLevelByName(nbt.getString("Level")).also { level = it } == null) {
1487+
val level: Level? = Server.instance.getLevelByName(nbt.getString("Level"))
1488+
if (level == null) {
14901489
this.level = Server.instance.defaultLevel
14911490
nbt.putString("Level", this.level!!.getLevelName())
14921491
val spawnLocation = this.level!!.safeSpawn
@@ -1905,10 +1904,10 @@ open class Player(
19051904
get() = this
19061905

19071906
override val firstPlayed: Long?
1908-
get() = if (this.namedTag != null) namedTag!!.getLong("firstPlayed") else null
1907+
get() = namedTag.getLong("firstPlayed")
19091908

19101909
override val lastPlayed: Long?
1911-
get() = if (this.namedTag != null) namedTag!!.getLong("lastPlayed") else null
1910+
get() = namedTag.getLong("lastPlayed")
19121911

19131912
override fun hasPlayedBefore(): Boolean {
19141913
return this.playedBefore
@@ -2908,18 +2907,16 @@ open class Player(
29082907
//鞘翅检查和耐久计算
29092908
if (this.isGliding()) {
29102909
val playerInventory = this.inventory
2911-
if (playerInventory != null) {
2912-
val chestplate = playerInventory.chestplate
2913-
if ((chestplate == null || chestplate.id != ItemID.ELYTRA)) {
2910+
val chestplate = playerInventory.chestplate
2911+
if (chestplate.id != ItemID.ELYTRA) {
2912+
this.setGliding(false)
2913+
} else if (this.age % (20 * (chestplate.getEnchantmentLevel(Enchantment.ID_DURABILITY) + 1)) == 0 && !isCreative) {
2914+
val newDamage = chestplate.damage + 1
2915+
if (newDamage < chestplate.maxDurability) {
2916+
chestplate.damage = newDamage
2917+
playerInventory.setChestplate(chestplate)
2918+
} else {
29142919
this.setGliding(false)
2915-
} else if (this.age % (20 * (chestplate.getEnchantmentLevel(Enchantment.ID_DURABILITY) + 1)) == 0 && !isCreative) {
2916-
val newDamage = chestplate.damage + 1
2917-
if (newDamage < chestplate.maxDurability) {
2918-
chestplate.damage = newDamage
2919-
playerInventory.setChestplate(chestplate)
2920-
} else {
2921-
this.setGliding(false)
2922-
}
29232920
}
29242921
}
29252922
}
@@ -3830,38 +3827,38 @@ open class Player(
38303827
saveNBT()
38313828

38323829
if (this.level != null) {
3833-
namedTag!!.putString("Level", level!!.getLevelName())
3830+
namedTag.putString("Level", level!!.getLevelName())
38343831

38353832
val achievements = CompoundTag()
38363833
for (achievement in this.achievements) {
38373834
achievements.putByte(achievement!!, 1)
38383835
}
38393836

3840-
namedTag!!.putCompound("Achievements", achievements)
3841-
namedTag!!.putInt("playerGameType", this.gamemode)
3842-
namedTag!!.putLong("lastPlayed", System.currentTimeMillis() / 1000)
3843-
namedTag!!.putString("lastIP", this.address)
3844-
namedTag!!.putInt("EXP", this.experience)
3845-
namedTag!!.putInt("expLevel", this.experienceLevel)
3846-
namedTag!!.putInt("foodLevel", foodData!!.getFood())
3847-
namedTag!!.putFloat("foodSaturationLevel", foodData!!.getSaturation())
3848-
namedTag!!.putInt("enchSeed", this.enchSeed)
3837+
namedTag.putCompound("Achievements", achievements)
3838+
namedTag.putInt("playerGameType", this.gamemode)
3839+
namedTag.putLong("lastPlayed", System.currentTimeMillis() / 1000)
3840+
namedTag.putString("lastIP", this.address)
3841+
namedTag.putInt("EXP", this.experience)
3842+
namedTag.putInt("expLevel", this.experienceLevel)
3843+
namedTag.putInt("foodLevel", foodData!!.getFood())
3844+
namedTag.putFloat("foodSaturationLevel", foodData!!.getSaturation())
3845+
namedTag.putInt("enchSeed", this.enchSeed)
38493846

38503847
val fogIdentifiers = ListTag<StringTag>()
38513848
val userProvidedFogIds = ListTag<StringTag>()
38523849
fogStack.forEach { fog ->
38533850
userProvidedFogIds.add(StringTag(fog.first))
38543851
fogIdentifiers.add(StringTag(fog.second))
38553852
}
3856-
namedTag!!.putList("fogIdentifiers", fogIdentifiers)
3857-
namedTag!!.putList("userProvidedFogIds", userProvidedFogIds)
3853+
namedTag.putList("fogIdentifiers", fogIdentifiers)
3854+
namedTag.putList("userProvidedFogIds", userProvidedFogIds)
38583855

3859-
namedTag!!.putInt("TimeSinceRest", this.timeSinceRest)
3856+
namedTag.putInt("TimeSinceRest", this.timeSinceRest)
38603857

3861-
if (getEntityName().isNotBlank() && this.namedTag != null) {
3858+
if (getEntityName().isNotBlank()) {
38623859
Server.instance.saveOfflinePlayerData(
38633860
uuid,
3864-
namedTag!!, async
3861+
namedTag, async
38653862
)
38663863
}
38673864
}
@@ -3896,7 +3893,7 @@ open class Player(
38963893
params.add(this.displayName)
38973894

38983895
run switch@{
3899-
when (if (cause == null) DamageCause.CUSTOM else cause.cause) {
3896+
when (cause?.cause ?: DamageCause.CUSTOM) {
39003897
DamageCause.ENTITY_ATTACK -> if (cause is EntityDamageByEntityEvent) {
39013898
val e = cause.damager
39023899
killer = e
@@ -4034,11 +4031,9 @@ open class Player(
40344031
}
40354032
}
40364033

4037-
if (this.offhandInventory != null) {
4038-
offhandInventory.contents.forEach { (slot, item) ->
4039-
if (!item.keepOnDeath()) {
4040-
offhandInventory.clear(slot)
4041-
}
4034+
offhandInventory.contents.forEach { (slot, item) ->
4035+
if (!item.keepOnDeath()) {
4036+
offhandInventory.clear(slot)
40424037
}
40434038
}
40444039
}
@@ -5102,7 +5097,7 @@ open class Player(
51025097
if (near) {
51035098
var inventory: Inventory? = this.inventory
51045099
if (entity is EntityArrow && entity.hadCollision) {
5105-
val item = if (entity.getArrowItem() != null) entity.getArrowItem() else ItemArrow()
5100+
val item = entity.getArrowItem()
51065101
if (!this.isCreative) {
51075102
// Should only collect to the offhand slot if the item matches what is already there
51085103
if (offhandInventory.getItem(0).id == item.id && offhandInventory.canAddItem(
@@ -5263,7 +5258,7 @@ open class Player(
52635258

52645259
override fun hashCode(): Int {
52655260
if ((this.hash == 0) || (this.hash == 485)) {
5266-
this.hash = (485 + (if (getUniqueID() != null) getUniqueID().hashCode() else 0))
5261+
this.hash = (485 + getUniqueID().hashCode())
52675262
}
52685263

52695264
return this.hash

src/jvmMain/kotlin/block/BlockAzalea.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ open class BlockAzalea @JvmOverloads constructor(blockstate: BlockState = proper
5959
val aged = chance > 0.8
6060
if (type == Level.BLOCK_UPDATE_NORMAL) {
6161
val down = down()
62-
if (down != null && !BlockFlower.isSupportValid(down)) {
62+
if (!BlockFlower.isSupportValid(down)) {
6363
level.useBreakOn(this.position)
6464
return Level.BLOCK_UPDATE_NORMAL
6565
}
@@ -92,7 +92,7 @@ open class BlockAzalea @JvmOverloads constructor(blockstate: BlockState = proper
9292
player: Player?
9393
): Boolean {
9494
val down = down()
95-
if (down != null && BlockFlower.isSupportValid(down)) {
95+
if (BlockFlower.isSupportValid(down)) {
9696
level.setBlock(block.position, this, direct = true, update = true)
9797
return true
9898
}

src/jvmMain/kotlin/block/BlockBubbleColumn.kt

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,49 +68,47 @@ class BlockBubbleColumn @JvmOverloads constructor(blockstate: BlockState = prope
6868
}
6969

7070
override fun onEntityCollide(entity: Entity) {
71-
if (entity != null) {
72-
if (entity.canBeMovedByCurrents()) {
73-
if (up().isAir) {
74-
if (isDragDown) {
75-
entity.motion.y = max(-0.9, entity.motion.y - 0.03)
76-
} else {
77-
if (entity is EntityPhysical && entity.motion.y < -entity.getGravity() * 8) {
78-
entity.motion.y = (-entity.getGravity() * 2).toDouble()
79-
}
80-
entity.motion.y = min(1.8, entity.motion.y + 0.1)
71+
if (entity.canBeMovedByCurrents()) {
72+
if (up().isAir) {
73+
if (isDragDown) {
74+
entity.motion.y = max(-0.9, entity.motion.y - 0.03)
75+
} else {
76+
if (entity is EntityPhysical && entity.motion.y < -entity.getGravity() * 8) {
77+
entity.motion.y = (-entity.getGravity() * 2).toDouble()
8178
}
79+
entity.motion.y = min(1.8, entity.motion.y + 0.1)
80+
}
8281

83-
val random = ThreadLocalRandom.current()
84-
for (i in 0..1) {
85-
level.addParticle(
86-
SplashParticle(
87-
position.add(
88-
random.nextFloat().toDouble(),
89-
(random.nextFloat() + 1).toDouble(),
90-
random.nextFloat().toDouble()
91-
)
82+
val random = ThreadLocalRandom.current()
83+
for (i in 0..1) {
84+
level.addParticle(
85+
SplashParticle(
86+
position.add(
87+
random.nextFloat().toDouble(),
88+
(random.nextFloat() + 1).toDouble(),
89+
random.nextFloat().toDouble()
9290
)
9391
)
94-
level.addParticle(
95-
BubbleParticle(
96-
position.add(
97-
random.nextFloat().toDouble(),
98-
(random.nextFloat() + 1).toDouble(),
99-
random.nextFloat().toDouble()
100-
)
92+
)
93+
level.addParticle(
94+
BubbleParticle(
95+
position.add(
96+
random.nextFloat().toDouble(),
97+
(random.nextFloat() + 1).toDouble(),
98+
random.nextFloat().toDouble()
10199
)
102100
)
103-
}
101+
)
102+
}
103+
} else {
104+
if (isDragDown) {
105+
entity.motion.y = max(-0.3, entity.motion.y - 0.3)
104106
} else {
105-
if (isDragDown) {
106-
entity.motion.y = max(-0.3, entity.motion.y - 0.3)
107-
} else {
108-
entity.motion.y = min(0.7, entity.motion.y + 0.06)
109-
}
107+
entity.motion.y = min(0.7, entity.motion.y + 0.06)
110108
}
111-
entity.motionChanged = true
112-
entity.resetFallDistance()
113109
}
110+
entity.motionChanged = true
111+
entity.resetFallDistance()
114112
}
115113
}
116114

src/jvmMain/kotlin/block/BlockComposter.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class BlockComposter @JvmOverloads constructor(blockstate: BlockState = properti
9595
return true
9696
}
9797

98-
if (player != null && !player.isCreative) {
98+
if (!player.isCreative) {
9999
item.setCount(item.getCount() - 1)
100100
}
101101

@@ -120,11 +120,9 @@ class BlockComposter @JvmOverloads constructor(blockstate: BlockState = properti
120120
val event = ComposterEmptyEvent(this, player!!, item!!, ItemBoneMeal(), 0)
121121
Server.instance.pluginManager.callEvent(event)
122122
if (!event.cancelled) {
123-
setPropertyValue<Int, IntPropertyType>(CommonBlockProperties.COMPOSTER_FILL_LEVEL, event.getNewLevel())
123+
setPropertyValue(CommonBlockProperties.COMPOSTER_FILL_LEVEL, event.getNewLevel())
124124
level.setBlock(this.position, this, direct = true, update = true)
125-
if (item != null) {
126-
level.dropItem(position.add(0.5, 0.85, 0.5), event.getDrop(), event.motion, false, 10)
127-
}
125+
level.dropItem(position.add(0.5, 0.85, 0.5), event.getDrop(), event.motion, false, 10)
128126
level.addSound(position.add(0.5, 0.5, 0.5), Sound.BLOCK_COMPOSTER_EMPTY)
129127
return event.getDrop()
130128
}

src/jvmMain/kotlin/block/BlockConcretePowder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class BlockConcretePowder(blockState: BlockState) : BlockFallable(block
3737

3838
override fun place(
3939
item: Item?,
40-
b: Block,
40+
block: Block,
4141
target: Block?,
4242
face: BlockFace,
4343
fx: Double,
@@ -48,8 +48,8 @@ abstract class BlockConcretePowder(blockState: BlockState) : BlockFallable(block
4848
var concrete = false
4949

5050
for (side in 1..5) {
51-
val block = this.getSide(fromIndex(side))
52-
if (block.id == BlockID.FLOWING_WATER || block.id == BlockID.WATER) {
51+
val side = this.getSide(fromIndex(side))
52+
if (side.id == BlockID.FLOWING_WATER || side.id == BlockID.WATER) {
5353
concrete = true
5454
break
5555
}

src/jvmMain/kotlin/block/BlockLichen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ abstract class BlockLichen(blockState: BlockState) : BlockTransparent(blockState
8686
override fun onUpdate(type: Int): Int {
8787
for (side in BlockFace.entries) {
8888
val support = this.getSide(side)
89-
if (isGrowthToSide(side) && support != null && !support.isSolid) {
89+
if (isGrowthToSide(side) && !support.isSolid) {
9090
this.witherAtSide(side)
9191
}
9292
}

src/jvmMain/kotlin/block/BlockObsidian.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BlockObsidian(blockState: BlockState = properties.defaultState) : BlockSol
2727
this.west(), this.east(),
2828
)
2929
for (aNearby in nearby) {
30-
if (aNearby != null && aNearby.id == BlockID.PORTAL) {
30+
if (aNearby.id == BlockID.PORTAL) {
3131
aNearby.onBreak(item)
3232
}
3333
}

src/jvmMain/kotlin/block/BlockPortal.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ class BlockPortal @JvmOverloads constructor(blockstate: BlockState = properties.
4747
var result = super.onBreak(item)
4848
for (face in BlockFace.entries) {
4949
val b = this.getSide(face)
50-
if (b != null) {
51-
if (b is BlockPortal) {
52-
result = result and b.onBreak(item)
53-
}
50+
if (b is BlockPortal) {
51+
result = result and b.onBreak(item)
5452
}
5553
}
5654
return result

src/jvmMain/kotlin/block/BlockPressurePlateBase.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.chorus_oss.chorus.block
33
import org.chorus_oss.chorus.Player
44
import org.chorus_oss.chorus.Server
55
import org.chorus_oss.chorus.block.property.CommonBlockProperties
6-
import org.chorus_oss.chorus.block.property.type.IntPropertyType
76
import org.chorus_oss.chorus.entity.Entity
87
import org.chorus_oss.chorus.event.Event
98
import org.chorus_oss.chorus.event.block.BlockRedstoneEvent
@@ -189,7 +188,7 @@ abstract class BlockPressurePlateBase(blockState: BlockState) : BlockFlowable(bl
189188
return true
190189
}
191190

192-
override fun getWeakPower(side: BlockFace): Int {
191+
override fun getWeakPower(face: BlockFace): Int {
193192
return redstonePower
194193
}
195194

@@ -198,9 +197,9 @@ abstract class BlockPressurePlateBase(blockState: BlockState) : BlockFlowable(bl
198197
}
199198

200199
var redstonePower: Int
201-
get() = getPropertyValue<Int, IntPropertyType>(CommonBlockProperties.REDSTONE_SIGNAL)
200+
get() = getPropertyValue(CommonBlockProperties.REDSTONE_SIGNAL)
202201
set(power) {
203-
setPropertyValue<Int, IntPropertyType>(CommonBlockProperties.REDSTONE_SIGNAL, power)
202+
setPropertyValue(CommonBlockProperties.REDSTONE_SIGNAL, power)
204203
}
205204

206205
protected fun playOnSound() {

0 commit comments

Comments
 (0)