init
This commit is contained in:
commit
849cb399a6
5 changed files with 93 additions and 0 deletions
40
src/main/java/pl/piecuu/invisninja/InvisNinja.java
Normal file
40
src/main/java/pl/piecuu/invisninja/InvisNinja.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package pl.piecuu.invisninja;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
public class InvisNinja extends JavaPlugin implements Listener {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||
Entity en = e.getDamageSource().getCausingEntity();
|
||||
if(!(en instanceof Player p)) return;
|
||||
if(!isPlayerInvisible(p)) return;
|
||||
|
||||
Component newMessage = e.deathMessage()
|
||||
.replaceText(TextReplacementConfig.builder()
|
||||
.match(p.getName())
|
||||
.replacement(Component.text("aaaaaaaaaaaaa").decoration(TextDecoration.OBFUSCATED, true))
|
||||
.build()
|
||||
);
|
||||
e.deathMessage(newMessage);
|
||||
}
|
||||
|
||||
public static boolean isPlayerInvisible(Player p) {
|
||||
return p.hasPotionEffect(PotionEffectType.INVISIBILITY);
|
||||
}
|
||||
}
|
||||
5
src/main/resources/plugin.yml
Normal file
5
src/main/resources/plugin.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
name: invisninja
|
||||
version: 1.0
|
||||
author: Piecuu
|
||||
main: pl.piecuu.invisninja.InvisNinja
|
||||
api-version: '1.21.11'
|
||||
Loading…
Add table
Add a link
Reference in a new issue