mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 14:38:58 +00:00
Merge pull request #32 from darbyjack/channel-join-event
Implemented PlayerJoinChatChannelEvent
This commit is contained in:
4 files changed
+45
No files matched your search
@@ -3,6 +3,7 @@ package com.palmergames.bukkit.TownyChat.Command;
|
|||||||
import com.palmergames.bukkit.TownyChat.Chat;
|
import com.palmergames.bukkit.TownyChat.Chat;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
|
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
|
||||||
|
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
|
||||||
import com.palmergames.bukkit.TownyChat.util.TownyUtil;
|
import com.palmergames.bukkit.TownyChat.util.TownyUtil;
|
||||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||||
import com.palmergames.bukkit.towny.command.BaseCommand;
|
import com.palmergames.bukkit.towny.command.BaseCommand;
|
||||||
@@ -389,6 +390,8 @@ public class ChannelCommand extends BaseCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerJoinChatChannelEvent(player, chan));
|
||||||
|
|
||||||
TownyMessaging.sendMessage(player, Translation.of("tc_you_joined_channel", chan.getName()));
|
TownyMessaging.sendMessage(player, Translation.of("tc_you_joined_channel", chan.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
@@ -2,6 +2,7 @@ package com.palmergames.bukkit.TownyChat.Command.commandobjects;
|
|||||||
|
|
||||||
import com.palmergames.bukkit.TownyChat.Chat;
|
import com.palmergames.bukkit.TownyChat.Chat;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||||
|
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
|
||||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||||
import com.palmergames.bukkit.towny.object.Translation;
|
import com.palmergames.bukkit.towny.object.Translation;
|
||||||
@@ -65,6 +66,7 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
|||||||
|
|
||||||
plugin.getTowny().setPlayerMode(player, modes, false);
|
plugin.getTowny().setPlayerMode(player, modes, false);
|
||||||
TownyMessaging.sendMessage(player, String.format(Translation.of("tc_you_are_now_talking_in_channel"), channel.getName()));
|
TownyMessaging.sendMessage(player, String.format(Translation.of("tc_you_are_now_talking_in_channel"), channel.getName()));
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerJoinChatChannelEvent(player, channel));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.palmergames.bukkit.TownyChat.HexFormatter;
|
|||||||
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
||||||
import com.palmergames.bukkit.TownyChat.config.ChatSettings;
|
import com.palmergames.bukkit.TownyChat.config.ChatSettings;
|
||||||
import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent;
|
import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent;
|
||||||
|
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
|
||||||
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
@@ -66,6 +67,7 @@ public class StandardChannel extends Channel {
|
|||||||
if (isAbsent(player.getName())) {
|
if (isAbsent(player.getName())) {
|
||||||
join(player.getName());
|
join(player.getName());
|
||||||
notifyjoin = true;
|
notifyjoin = true;
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerJoinChatChannelEvent(player, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.palmergames.bukkit.TownyChat.events;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Glare
|
||||||
|
* Date: 12/14/2020
|
||||||
|
* Time: 4:56 PM
|
||||||
|
*/
|
||||||
|
public class PlayerJoinChatChannelEvent extends Event {
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
private final Player player;
|
||||||
|
private final Channel channel;
|
||||||
|
|
||||||
|
public PlayerJoinChatChannelEvent(Player player, Channel channel) {
|
||||||
|
this.player = player;
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user