Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
feat: #196 極端に大きいスライム・マグマキューブを召喚できないように
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 committed Jan 27, 2022
1 parent f2c1914 commit 866fd49
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/main/java/com/jaoafa/mymaid4/event/Event_AntiBigSlime.java
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 866fd49

Please sign in to comment.