Skip to content

Commit a8b9789

Browse files
Add basic SCP-268 system
1 parent 455e57c commit a8b9789

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

src/main/java/dev/enderman/minecraft/plugins/scp/SCPPlugin.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dev.enderman.minecraft.plugins.scp
22

33
import dev.enderman.minecraft.plugins.scp.entities.SCP018Entity
44
import dev.enderman.minecraft.plugins.scp.items.SCP018Item
5+
import dev.enderman.minecraft.plugins.scp.items.SCP268Item
56
import dev.jorel.commandapi.CommandAPI
67
import dev.jorel.commandapi.CommandAPIBukkitConfig
78
import foundation.esoteric.minecraft.plugins.library.commands.GiveCustomItemCommand
@@ -10,17 +11,22 @@ import foundation.esoteric.minecraft.plugins.library.entity.CustomEntityPlugin
1011
import foundation.esoteric.minecraft.plugins.library.item.CustomItemManager
1112
import foundation.esoteric.minecraft.plugins.library.item.CustomItemPlugin
1213
import foundation.esoteric.minecraft.plugins.library.pack.resource.ResourcePackManager
14+
import gg.flyte.twilight.Twilight
1315
import org.bukkit.plugin.java.JavaPlugin
1416

1517
class SCPPlugin : JavaPlugin(), CustomItemPlugin, CustomEntityPlugin {
1618

1719
override lateinit var customItemManager: CustomItemManager
1820
override lateinit var customEntityManager: CustomEntityManager
1921

22+
lateinit var twilight: Twilight
23+
2024
override fun onEnable() {
2125
customItemManager = CustomItemManager(this)
2226
customEntityManager = CustomEntityManager(this)
2327

28+
twilight = Twilight(this)
29+
2430
dataFolder.mkdir()
2531
saveDefaultConfig()
2632

@@ -32,6 +38,8 @@ class SCPPlugin : JavaPlugin(), CustomItemPlugin, CustomEntityPlugin {
3238
SCP018Entity(this)
3339
SCP018Item(this)
3440

41+
SCP268Item(this)
42+
3543
ResourcePackManager(this)
3644

3745
GiveCustomItemCommand(this)
Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
11
package dev.enderman.minecraft.plugins.scp.items
22

3+
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent
34
import dev.enderman.minecraft.plugins.scp.SCPPlugin
45
import foundation.esoteric.minecraft.plugins.library.item.TexturedItem
6+
import gg.flyte.twilight.extension.hidePlayer
7+
import gg.flyte.twilight.extension.showPlayer
58
import org.bukkit.Material
9+
import org.bukkit.event.EventHandler
10+
import org.bukkit.potion.PotionEffect
11+
import org.bukkit.potion.PotionEffectType
612

713
class SCP268Item(plugin: SCPPlugin) : TexturedItem(plugin, "scp_268", Material.LEATHER_HELMET) {
14+
@EventHandler
15+
private fun onEquip(event: PlayerArmorChangeEvent) {
16+
val player = event.player
817

9-
init {
10-
println(this::class.qualifiedName.hashCode())
11-
}
18+
val newItem = event.newItem
19+
val oldItem = event.oldItem
20+
21+
if (isItem(newItem)) {
22+
plugin.logger.info("[SCP-268] The player has put on the hat... now invisible.")
23+
player.hidePlayer(plugin, player)
24+
player.hidePlayer()
25+
26+
player.addPotionEffect(
27+
PotionEffect(
28+
PotionEffectType.INVISIBILITY,
29+
PotionEffect.INFINITE_DURATION,
30+
1,
31+
false,
32+
false,
33+
false
34+
)
35+
)
36+
}
1237

38+
if (isItem(oldItem)) {
39+
plugin.logger.info("[SCP-268] The player has taken off the hat... now visible.")
40+
player.showPlayer(plugin, player)
41+
player.showPlayer()
42+
43+
player.removePotionEffect(
44+
PotionEffectType.INVISIBILITY
45+
)
46+
}
47+
}
1348
}

0 commit comments

Comments
 (0)