From 866fd491d4b00347100380d2ec71f935d74ac9d0 Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Thu, 27 Jan 2022 11:42:13 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#196=20=E6=A5=B5=E7=AB=AF=E3=81=AB?= =?UTF-8?q?=E5=A4=A7=E3=81=8D=E3=81=84=E3=82=B9=E3=83=A9=E3=82=A4=E3=83=A0?= =?UTF-8?q?=E3=83=BB=E3=83=9E=E3=82=B0=E3=83=9E=E3=82=AD=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=96=E3=82=92=E5=8F=AC=E5=96=9A=E3=81=A7=E3=81=8D=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mymaid4/event/Event_AntiBigSlime.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/com/jaoafa/mymaid4/event/Event_AntiBigSlime.java diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_AntiBigSlime.java b/src/main/java/com/jaoafa/mymaid4/event/Event_AntiBigSlime.java new file mode 100644 index 000000000..99b756805 --- /dev/null +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_AntiBigSlime.java @@ -0,0 +1,59 @@ +/* + * jaoLicense + * + * Copyright (c) 2022 jao Minecraft Server + * + * The following license applies to this project: jaoLicense + * + * Japanese: https://github.com/jaoafa/jao-Minecraft-Server/blob/master/jaoLICENSE.md + * English: https://github.com/jaoafa/jao-Minecraft-Server/blob/master/jaoLICENSE-en.md + */ + +package com.jaoafa.mymaid4.event; + +import com.jaoafa.mymaid4.lib.EventPremise; +import com.jaoafa.mymaid4.lib.MyMaidLibrary; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; + +public class Event_AntiBigSlime extends MyMaidLibrary implements Listener, EventPremise { + @Override + public String description() { + return "極端に大きいスライム・マグマキューブを召喚できないようにします。"; + } + + @EventHandler + public void onCreatureSpawn(CreatureSpawnEvent event) { + if (!(event.getEntity() instanceof Slime slime)) { + return; + } + if (slime.getSize() <= 30) { + return; + } + event.setCancelled(true); + Location location = event.getLocation(); + Player nearPlayer = getNearestPlayer(location); + event.setCancelled(true); + if (nearPlayer == null) { + return; + } + nearPlayer.sendMessage(Component.text().append( + Component.text("[AntiBigSlime]"), + Component.space(), + Component.text("負荷対策の為に極端に大きいスライム・マグマキューブの召喚を禁止しています。ご協力をお願いします。", NamedTextColor.GREEN) + )); + sendAM(Component.text().append( + Component.text("["), + Component.text("AntiBigSlime", NamedTextColor.RED), + Component.text("]"), + Component.space(), + Component.text(nearPlayer.getName() + "の近くで極端に大きいスライム・マグマキューブが発生しましたが、発生を規制されました。", NamedTextColor.GREEN) + ).build()); + } +}