Reorganized lots of stuff (components) #86

Merged
NorbiPeti merged 12 commits from dev into master 2019-01-03 20:39:53 +00:00
4 changed files with 19 additions and 6 deletions
Showing only changes of commit 68e69782ee - Show all commits

View file

@ -38,7 +38,7 @@ public class MCListener implements Listener {
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) {
callEventExcluding(event, false, EXCLUDED_PLUGINS);

View file

@ -240,7 +240,8 @@ public class MCChatListener implements Listener {
&& !(ev.getMessage().getChannel().isPrivate() && MCChatPrivate.isMinecraftChatEnabled(author.getStringID()))
&& !hasCustomChat)
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("/", "")
.equalsIgnoreCase("mcchat")) //Either mcchat or /mcchat
return false; //Allow disabling the chat if needed

View file

@ -2,9 +2,11 @@ package buttondevteam.discordplugin.mcchat;
import buttondevteam.discordplugin.DiscordConnectedPlayer;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.lib.player.TBMCPlayer;
import lombok.val;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import sx.blah.discord.handle.obj.IChannel;
@ -31,13 +33,13 @@ public class MCChatPrivate {
val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID(), op.getName());
MCChatUtils.addSender(MCChatUtils.ConnectedSenders, user, sender);
if (p == null)// Player is offline - If the player is online, that takes precedence
callEventExcludingSome(new PlayerJoinEvent(sender, ""));
callEventSync(new PlayerJoinEvent(sender, ""));
} else {
val sender = MCChatUtils.removeSender(MCChatUtils.ConnectedSenders, channel, user);
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)
MCChatUtils.lastmsgfromd.remove(channel.getLongID());
return start //
@ -57,7 +59,11 @@ public class MCChatPrivate {
public static void logoutAll() {
for (val entry : MCChatUtils.ConnectedSenders.entrySet())
for (val valueEntry : entry.getValue().entrySet())
callEventExcludingSome(new PlayerQuitEvent(valueEntry.getValue(), ""));
callEventExcludingSome(new PlayerQuitEvent(valueEntry.getValue(), "")); //This is sync
MCChatUtils.ConnectedSenders.clear();
}
private static void callEventSync(Event event) {
Bukkit.getScheduler().runTask(DiscordPlugin.plugin, () -> callEventExcludingSome(event));
}
}

View file

@ -9,6 +9,7 @@ import com.earth2me.essentials.CommandSource;
import lombok.val;
import net.ess3.api.events.AfkStatusChangeEvent;
import net.ess3.api.events.MuteStatusChangeEvent;
import net.ess3.api.events.NickChangeEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -144,4 +145,9 @@ class MCListener implements Listener {
//Channel channel = ChromaGamerBase.getFromSender(event.getSender()).channel().get(); - TODO
MCChatUtils.forAllMCChat(MCChatUtils.send(name + " <:YEEHAW:" + DiscordPlugin.mainServer.getEmojiByName("YEEHAW").getStringID() + ">s"));
}
@EventHandler
public void onNickChange(NickChangeEvent event) {
MCChatUtils.updatePlayerList();
}
}