From 5b13548fa4b80af6e9db10d6fa7e428801f03788 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 18 Nov 2016 22:48:49 +0100 Subject: [PATCH] Started chat msg sending API... --- .../java/buttondevteam/lib/TBMCChatEvent.java | 47 +++++++++++++++++++ .../buttondevteam/lib/chat/TBMCChatAPI.java | 5 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/main/java/buttondevteam/lib/TBMCChatEvent.java diff --git a/src/main/java/buttondevteam/lib/TBMCChatEvent.java b/src/main/java/buttondevteam/lib/TBMCChatEvent.java new file mode 100644 index 0000000..2f00575 --- /dev/null +++ b/src/main/java/buttondevteam/lib/TBMCChatEvent.java @@ -0,0 +1,47 @@ +package buttondevteam.lib; + +import org.bukkit.command.CommandSender; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import buttondevteam.lib.chat.Channel; + +public class TBMCChatEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private Channel channel; + private CommandSender sender; + private String message; + + public TBMCChatEvent(CommandSender sender, Channel channel, String message) { + this.sender = sender; + this.channel = channel; + this.message = message; // TODO: Message object with data? + } + + /* + * public TBMCPlayer getPlayer() { return TBMCPlayer.getPlayer(sender); // TODO: Get Chroma user } + */ + + public Channel getChannel() { + return channel; + } + + public CommandSender getSender() { + return sender; + } + + public String getMessage() { + return message; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + +} diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 1be4cda..3a62ef6 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -6,6 +6,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; import org.reflections.Reflections; @@ -13,6 +14,7 @@ import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; +import buttondevteam.lib.TBMCChatEvent; import buttondevteam.lib.TBMCCoreAPI; public class TBMCChatAPI { @@ -174,6 +176,7 @@ public class TBMCChatAPI { } public static void SendChatMessage(Channel channel, CommandSender sender, String message) { - // TODO + TBMCChatEvent event = new TBMCChatEvent(sender, channel, message); + Bukkit.getPluginManager().callEvent(event); } }