parent
040373280e
commit
68e69782ee
4 changed files with 19 additions and 6 deletions
|
@ -38,7 +38,7 @@ public class MCListener implements Listener {
|
||||||
DiscordPlugin.Restart = !e.getCommand().equalsIgnoreCase("stop"); // The variable is always true except if stopped
|
DiscordPlugin.Restart = !e.getCommand().equalsIgnoreCase("stop"); // The variable is always true except if stopped
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] EXCLUDED_PLUGINS = {"ProtocolLib", "LibsDisguises"};
|
private static final String[] EXCLUDED_PLUGINS = {"ProtocolLib", "LibsDisguises", "JourneyMapServer"}; //TODO: Make configurable
|
||||||
|
|
||||||
public static void callEventExcludingSome(Event event) {
|
public static void callEventExcludingSome(Event event) {
|
||||||
callEventExcluding(event, false, EXCLUDED_PLUGINS);
|
callEventExcluding(event, false, EXCLUDED_PLUGINS);
|
||||||
|
|
|
@ -240,7 +240,8 @@ public class MCChatListener implements Listener {
|
||||||
&& !(ev.getMessage().getChannel().isPrivate() && MCChatPrivate.isMinecraftChatEnabled(author.getStringID()))
|
&& !(ev.getMessage().getChannel().isPrivate() && MCChatPrivate.isMinecraftChatEnabled(author.getStringID()))
|
||||||
&& !hasCustomChat)
|
&& !hasCustomChat)
|
||||||
return false; //Chat isn't enabled on this channel
|
return false; //Chat isn't enabled on this channel
|
||||||
if (hasCustomChat && ev.getMessage().getContent().length() < "/mcchat<>".length()
|
if (ev.getMessage().getChannel().isPrivate() //Only in private chat
|
||||||
|
&& ev.getMessage().getContent().length() < "/mcchat<>".length()
|
||||||
&& ev.getMessage().getContent().replace("/", "")
|
&& ev.getMessage().getContent().replace("/", "")
|
||||||
.equalsIgnoreCase("mcchat")) //Either mcchat or /mcchat
|
.equalsIgnoreCase("mcchat")) //Either mcchat or /mcchat
|
||||||
return false; //Allow disabling the chat if needed
|
return false; //Allow disabling the chat if needed
|
||||||
|
|
|
@ -2,9 +2,11 @@ package buttondevteam.discordplugin.mcchat;
|
||||||
|
|
||||||
import buttondevteam.discordplugin.DiscordConnectedPlayer;
|
import buttondevteam.discordplugin.DiscordConnectedPlayer;
|
||||||
import buttondevteam.discordplugin.DiscordPlayer;
|
import buttondevteam.discordplugin.DiscordPlayer;
|
||||||
|
import buttondevteam.discordplugin.DiscordPlugin;
|
||||||
import buttondevteam.lib.player.TBMCPlayer;
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import sx.blah.discord.handle.obj.IChannel;
|
import sx.blah.discord.handle.obj.IChannel;
|
||||||
|
@ -31,13 +33,13 @@ public class MCChatPrivate {
|
||||||
val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID(), op.getName());
|
val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID(), op.getName());
|
||||||
MCChatUtils.addSender(MCChatUtils.ConnectedSenders, user, sender);
|
MCChatUtils.addSender(MCChatUtils.ConnectedSenders, user, sender);
|
||||||
if (p == null)// Player is offline - If the player is online, that takes precedence
|
if (p == null)// Player is offline - If the player is online, that takes precedence
|
||||||
callEventExcludingSome(new PlayerJoinEvent(sender, ""));
|
callEventSync(new PlayerJoinEvent(sender, ""));
|
||||||
} else {
|
} else {
|
||||||
val sender = MCChatUtils.removeSender(MCChatUtils.ConnectedSenders, channel, user);
|
val sender = MCChatUtils.removeSender(MCChatUtils.ConnectedSenders, channel, user);
|
||||||
if (p == null)// Player is offline - If the player is online, that takes precedence
|
if (p == null)// Player is offline - If the player is online, that takes precedence
|
||||||
callEventExcludingSome(new PlayerQuitEvent(sender, ""));
|
callEventSync(new PlayerQuitEvent(sender, ""));
|
||||||
}
|
}
|
||||||
}
|
} // ---- PermissionsEx warning is normal on logout ----
|
||||||
if (!start)
|
if (!start)
|
||||||
MCChatUtils.lastmsgfromd.remove(channel.getLongID());
|
MCChatUtils.lastmsgfromd.remove(channel.getLongID());
|
||||||
return start //
|
return start //
|
||||||
|
@ -57,7 +59,11 @@ public class MCChatPrivate {
|
||||||
public static void logoutAll() {
|
public static void logoutAll() {
|
||||||
for (val entry : MCChatUtils.ConnectedSenders.entrySet())
|
for (val entry : MCChatUtils.ConnectedSenders.entrySet())
|
||||||
for (val valueEntry : entry.getValue().entrySet())
|
for (val valueEntry : entry.getValue().entrySet())
|
||||||
callEventExcludingSome(new PlayerQuitEvent(valueEntry.getValue(), ""));
|
callEventExcludingSome(new PlayerQuitEvent(valueEntry.getValue(), "")); //This is sync
|
||||||
MCChatUtils.ConnectedSenders.clear();
|
MCChatUtils.ConnectedSenders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void callEventSync(Event event) {
|
||||||
|
Bukkit.getScheduler().runTask(DiscordPlugin.plugin, () -> callEventExcludingSome(event));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.earth2me.essentials.CommandSource;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||||
import net.ess3.api.events.MuteStatusChangeEvent;
|
import net.ess3.api.events.MuteStatusChangeEvent;
|
||||||
|
import net.ess3.api.events.NickChangeEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -144,4 +145,9 @@ class MCListener implements Listener {
|
||||||
//Channel channel = ChromaGamerBase.getFromSender(event.getSender()).channel().get(); - TODO
|
//Channel channel = ChromaGamerBase.getFromSender(event.getSender()).channel().get(); - TODO
|
||||||
MCChatUtils.forAllMCChat(MCChatUtils.send(name + " <:YEEHAW:" + DiscordPlugin.mainServer.getEmojiByName("YEEHAW").getStringID() + ">s"));
|
MCChatUtils.forAllMCChat(MCChatUtils.send(name + " <:YEEHAW:" + DiscordPlugin.mainServer.getEmojiByName("YEEHAW").getStringID() + ">s"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onNickChange(NickChangeEvent event) {
|
||||||
|
MCChatUtils.updatePlayerList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue