Fixes & fromcmd

- Exception handling got extra parenthesis
- Async player join event handling
- Added fromcmd check (shows /tableflip and similar)
This commit is contained in:
Norbi Peti 2018-06-03 02:44:32 +02:00
parent aabdd3a914
commit b350be608a
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 25 additions and 23 deletions

View file

@ -23,8 +23,8 @@ public class ExceptionListener implements Listener {
return; return;
if (lastthrown.stream() if (lastthrown.stream()
.anyMatch(ex -> Arrays.equals(e.getException().getStackTrace(), ex.getStackTrace()) .anyMatch(ex -> Arrays.equals(e.getException().getStackTrace(), ex.getStackTrace())
&& e.getException().getMessage() == null ? ex.getMessage() == null && (e.getException().getMessage() == null ? ex.getMessage() == null
: e.getException().getMessage().equals(ex.getMessage())) // e.Exception.Message==ex.Message : e.getException().getMessage().equals(ex.getMessage()))) // e.Exception.Message==ex.Message
&& lastsourcemsg.contains(e.getSourceMessage())) && lastsourcemsg.contains(e.getSourceMessage()))
return; return;
SendException(e.getException(), e.getSourceMessage()); SendException(e.getException(), e.getSourceMessage());

View file

@ -121,7 +121,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|| ((DiscordSenderBase) e.getSender()).getChannel().getLongID() != ch.getLongID(); || ((DiscordSenderBase) e.getSender()).getChannel().getLongID() != ch.getLongID();
if ((e.getChannel() == Channel.GlobalChat || e.getChannel().ID.equals("rp")) if ((e.getChannel() == Channel.GlobalChat || e.getChannel().ID.equals("rp"))
&& isdifferentchannel.test(DiscordPlugin.chatchannel)) && (!e.isFromcmd() || isdifferentchannel.test(DiscordPlugin.chatchannel)))
doit.accept(lastmsgdata == null doit.accept(lastmsgdata == null
? lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel, null, null) ? lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel, null, null)
: lastmsgdata); : lastmsgdata);

View file

@ -45,26 +45,28 @@ public class MCListener implements Listener {
public void onPlayerJoin(TBMCPlayerJoinEvent e) { public void onPlayerJoin(TBMCPlayerJoinEvent e) {
if (e.getPlayer() instanceof DiscordConnectedPlayer) if (e.getPlayer() instanceof DiscordConnectedPlayer)
return; // Don't show the joined message for the fake player return; // Don't show the joined message for the fake player
final Player p = e.getPlayer(); Bukkit.getScheduler().runTaskAsynchronously(DiscordPlugin.plugin, () -> {
DiscordPlayer dp = e.GetPlayer().getAs(DiscordPlayer.class); final Player p = e.getPlayer();
if (dp != null) { DiscordPlayer dp = e.GetPlayer().getAs(DiscordPlayer.class);
val user = DiscordPlugin.dc.getUserByID(Long.parseLong(dp.getDiscordID())); if (dp != null) {
MCChatListener.OnlineSenders.put(dp.getDiscordID(), val user = DiscordPlugin.dc.getUserByID(Long.parseLong(dp.getDiscordID()));
new DiscordPlayerSender(user, user.getOrCreatePMChannel(), p)); MCChatListener.OnlineSenders.put(dp.getDiscordID(),
MCChatListener.OnlineSenders.put("P" + dp.getDiscordID(), new DiscordPlayerSender(user, user.getOrCreatePMChannel(), p));
new DiscordPlayerSender(user, DiscordPlugin.chatchannel, p)); MCChatListener.OnlineSenders.put("P" + dp.getDiscordID(),
} new DiscordPlayerSender(user, DiscordPlugin.chatchannel, p));
if (ConnectCommand.WaitingToConnect.containsKey(e.GetPlayer().PlayerName().get())) { }
IUser user = DiscordPlugin.dc if (ConnectCommand.WaitingToConnect.containsKey(e.GetPlayer().PlayerName().get())) {
.getUserByID(Long.parseLong(ConnectCommand.WaitingToConnect.get(e.GetPlayer().PlayerName().get()))); IUser user = DiscordPlugin.dc
p.sendMessage("§bTo connect with the Discord account @" + user.getName() + "#" + user.getDiscriminator() .getUserByID(Long.parseLong(ConnectCommand.WaitingToConnect.get(e.GetPlayer().PlayerName().get())));
+ " do /discord accept"); p.sendMessage("§bTo connect with the Discord account @" + user.getName() + "#" + user.getDiscriminator()
p.sendMessage("§bIf it wasn't you, do /discord decline"); + " do /discord accept");
} p.sendMessage("§bIf it wasn't you, do /discord decline");
if (!DiscordPlugin.hooked) }
MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " joined the game"); if (!DiscordPlugin.hooked)
MCChatListener.ListC = 0; MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " joined the game");
ChromaBot.getInstance().updatePlayerList(); MCChatListener.ListC = 0;
ChromaBot.getInstance().updatePlayerList();
});
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)