Added two new versions (0.2.0 removes the DamageListener and 0.2.1 adds the start of the command /set-chat-color to set the color of the display name

This commit is contained in:
BlueFox 2024-05-20 19:10:02 +02:00
parent 31b233f50a
commit a381034a8f
11 changed files with 42 additions and 33 deletions

View File

@ -12,7 +12,6 @@ Listeners that are implemented by this plugin:
- also shows players that are op in the display name
- PlayerQuitEvent (print a beautified quit message "<< PlayerName")
- PlayerChatEvent (deprecated, but beautify chat messages "PlayerName: message")
- EntityDamageEvent (show who got how much damage from whom)
And all that in beautiful colors!

View File

@ -6,7 +6,7 @@
<groupId>de.privacynerd</groupId>
<artifactId>ChatBeautifier</artifactId>
<version>0.1.0</version>
<version>0.2.1</version>
<packaging>jar</packaging>
<name>ChatBeautifier</name>

View File

@ -3,6 +3,8 @@ package de.privacynerd.chatbeautifier;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import de.privacynerd.chatbeautifier.commands.*;
import de.privacynerd.chatbeautifier.guis.*;
public final class ChatBeautifier extends JavaPlugin {
@ -25,8 +27,8 @@ public final class ChatBeautifier extends JavaPlugin {
log("JoinQuitListener has been registered.");
pluginManager.registerEvents(new ChatListener(), this);
log("ChatListener has been registered.");
pluginManager.registerEvents(new DamageListener(), this);
log("DamageListener has been registered.");
Bukkit.getPluginCommand("set-chat-color").setExecutor(new ChatColorCommand());
log("Plugin enabled.");
}

View File

@ -1,29 +0,0 @@
package de.privacynerd.chatbeautifier;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
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.EntityDamageEvent;
public class DamageListener implements Listener {
@EventHandler
public void onPlayerGetDamage(EntityDamageEvent event) {
Entity player1 = event.getEntity();
if(!(player1 instanceof Player)){
return;
}
Player player = (Player) player1;
Server server = Bukkit.getServer();
Component message = Component.text(ChatColor.BOLD + "§4[Schaden] " + ChatColor.WHITE + "Der Spieler " + player.getDisplayName() + ChatColor.WHITE + " hat durch \n" + ChatColor.AQUA + event.getCause() + " " + ChatColor.RED + event.getDamage() / 2 + " Herzen " + ChatColor.WHITE + "Schaden bekommen");
server.broadcast(message);
}
}

View File

@ -0,0 +1,26 @@
package de.privacynerd.chatbeautifier.commands;
import de.privacynerd.chatbeautifier.ChatBeautifier;
import net.kyori.adventure.text.Component;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ChatColorCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
ChatBeautifier.INSTANCE.log("Command /set-chat-name executed");
if(!(commandSender instanceof Player)) {
ChatBeautifier.INSTANCE.log("Du bist kein Spieler.");
return true;
}
Player player = (Player) commandSender;
player.sendMessage(Component.text("Dieses Kommando befindet sich noch in der Mache!"));
return true;
}
}

View File

@ -0,0 +1,5 @@
package de.privacynerd.chatbeautifier.guis;
public class ChooseChatColor {
}

View File

@ -2,3 +2,9 @@ name: ChatBeautifier
version: '${project.version}'
main: de.privacynerd.chatbeautifier.ChatBeautifier
api-version: '1.20'
commands:
set-chat-color:
description: Mit diesem Befehl kannst du die Farbe deines Namens setzen.
aliases: ["scc"]
usage: /set-chat-color

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.