Skip to content

Commit 6b03972

Browse files
Use early return
1 parent 098a9c7 commit 6b03972

File tree

1 file changed

+29
-29
lines changed
  • src/main/java/dev/enderman/minecraft/plugins/scp/items

1 file changed

+29
-29
lines changed

src/main/java/dev/enderman/minecraft/plugins/scp/items/SCP268Item.kt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,34 @@ class SCP268Item(plugin: SCPPlugin) : TexturedItem(plugin, "scp_268", Material.L
5959

6060
val newItem = event.newItem
6161

62-
if (isItem(newItem)) {
63-
plugin.logger.info("[SCP-268] The player has put on the hat... now invisible.")
64-
player.hidePlayer(plugin, player)
65-
player.hidePlayer()
66-
67-
player.addPotionEffect(
68-
PotionEffect(
69-
PotionEffectType.INVISIBILITY,
70-
PotionEffect.INFINITE_DURATION,
71-
1,
72-
false,
73-
false,
74-
false
75-
)
62+
if (!isItem(newItem)) return
63+
64+
plugin.logger.info("[SCP-268] The player has put on the hat... now invisible.")
65+
player.hidePlayer(plugin, player)
66+
player.hidePlayer()
67+
68+
player.addPotionEffect(
69+
PotionEffect(
70+
PotionEffectType.INVISIBILITY,
71+
PotionEffect.INFINITE_DURATION,
72+
1,
73+
false,
74+
false,
75+
false
7676
)
77+
)
7778

78-
for (entity in player.world.livingEntities) {
79-
if (entity !is Mob) continue
79+
for (entity in player.world.livingEntities) {
80+
if (entity !is Mob) continue
8081

8182

82-
if (confusedEntities.contains(entity.type) && Math.random() > 0.75) return
83+
if (confusedEntities.contains(entity.type) && Math.random() > 0.75) return
8384

84-
if (unaffectedEntities.contains(entity.type) || lessAffectedEntities.contains(entity.type)) continue
85+
if (unaffectedEntities.contains(entity.type) || lessAffectedEntities.contains(entity.type)) continue
8586

86-
if (entity.target != player) continue
87+
if (entity.target != player) continue
8788

88-
entity.target = null
89-
}
89+
entity.target = null
9090
}
9191
}
9292

@@ -95,15 +95,15 @@ class SCP268Item(plugin: SCPPlugin) : TexturedItem(plugin, "scp_268", Material.L
9595
val player = event.player
9696
val oldItem = event.oldItem
9797

98-
if (isItem(oldItem)) {
99-
plugin.logger.info("[SCP-268] The player has taken off the hat... now visible.")
100-
player.showPlayer(plugin, player)
101-
player.showPlayer()
98+
if (!isItem(oldItem)) return
10299

103-
player.removePotionEffect(
104-
PotionEffectType.INVISIBILITY
105-
)
106-
}
100+
plugin.logger.info("[SCP-268] The player has taken off the hat... now visible.")
101+
player.showPlayer(plugin, player)
102+
player.showPlayer()
103+
104+
player.removePotionEffect(
105+
PotionEffectType.INVISIBILITY
106+
)
107107
}
108108

109109
@EventHandler

0 commit comments

Comments
 (0)