Skip to content

Commit

Permalink
Merge pull request #1889 from GiganticMinecraft/fix/valentine-pigman
Browse files Browse the repository at this point in the history
ゾンビピッグマンとウィッチからチョコクッキーをドロップさせない
  • Loading branch information
rito528 authored Feb 9, 2023
2 parents 2f14d98 + 19749d6 commit 90ac391
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,44 @@ class ValentineListener[F[_]: ConcurrentEffect: NonServerThreadContextShift](
ioOnMainThread: OnMinecraftServerThread[IO]
) extends Listener {

// クリーパーが爆発した場合、確率でアイテムをドロップ
@EventHandler
def onEntityExplode(event: EntityExplodeEvent): Unit = {
val entity = event.getEntity
if (!isInEvent || entity == null) return
if (!isInEvent) return

if (entity.isInstanceOf[Monster] && entity.isDead) {
randomlyDropItemAt(entity, droppedCookie, itemDropRate)
event.getEntity match {
case monster: Monster if monster.isDead && monster.getType == EntityType.CREEPER =>
randomlyDropItemAt(monster, droppedCookie, itemDropRate)
case _ =>
}
}

// モンスターの死因がクリーパーによる爆発の場合、確率でアイテムをドロップ
@EventHandler
def onEntityDeath(event: EntityDamageByEntityEvent): Unit = {
if (!isInEvent) return
if (event.getCause != DamageCause.ENTITY_EXPLOSION) return

val damager = event.getDamager
if (damager == null) return

if (event.getCause != DamageCause.ENTITY_EXPLOSION || damager.getType != EntityType.CREEPER)
return
if (damager == null || damager.getType != EntityType.CREEPER) return

val excludedMonsters = Set(EntityType.WITCH, EntityType.PIG_ZOMBIE)
event.getEntity match {
case monster: Monster =>
val entityMaxHealth = monster.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue
// monsterが死んだならば
case damaged: Monster if !excludedMonsters.contains(damaged.getType) =>
val entityMaxHealth = damaged.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue
// damagedが死んだならば
if (entityMaxHealth <= event.getDamage) {
randomlyDropItemAt(monster, droppedCookie, itemDropRate)
randomlyDropItemAt(damaged, droppedCookie, itemDropRate)
}
case _ =>
}
}

@EventHandler
def onPlayerJoinEvent(event: PlayerJoinEvent): Unit = {
if (isInEvent) {
Seq(
s"$LIGHT_PURPLE${END_DATE_TIME}までの期間限定で、イベント『バレンタインイベント${EVENT_YEAR}』を開催しています。",
s"$LIGHT_PURPLE${END_DATE_TIME}までの期間限定で、イベント『バレンタインイベント$EVENT_YEAR』を開催しています。",
"詳しくは下記URLのサイトをご覧ください。",
s"$DARK_GREEN$UNDERLINE$blogArticleUrl"
).foreach(event.getPlayer.sendMessage(_))
Expand Down

0 comments on commit 90ac391

Please sign in to comment.