Made last chat msg reset on sendMessage
This commit is contained in:
parent
9269e0fb19
commit
237559d663
3 changed files with 14 additions and 9 deletions
|
@ -70,6 +70,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
public static IChannel botroomchannel;
|
public static IChannel botroomchannel;
|
||||||
public static IChannel officechannel;
|
public static IChannel officechannel;
|
||||||
public static IChannel coffeechannel;
|
public static IChannel coffeechannel;
|
||||||
|
public static IChannel updatechannel;
|
||||||
public static IGuild mainServer;
|
public static IGuild mainServer;
|
||||||
public static IGuild devServer;
|
public static IGuild devServer;
|
||||||
|
|
||||||
|
@ -91,6 +92,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
botroomchannel = devServer.getChannelByID("239519012529111040"); // bot-room
|
botroomchannel = devServer.getChannelByID("239519012529111040"); // bot-room
|
||||||
officechannel = devServer.getChannelByID("219626707458457603"); // developers-office
|
officechannel = devServer.getChannelByID("219626707458457603"); // developers-office
|
||||||
coffeechannel = devServer.getChannelByID("219530035365675010"); // coffee-table
|
coffeechannel = devServer.getChannelByID("219530035365675010"); // coffee-table
|
||||||
|
updatechannel = devServer.getChannelByID("233724163519414272"); // server-updates
|
||||||
dc.changeStatus(Status.game("on TBMC"));
|
dc.changeStatus(Status.game("on TBMC"));
|
||||||
} else {
|
} else {
|
||||||
botchannel = devServer.getChannelByID("239519012529111040"); // bot-room
|
botchannel = devServer.getChannelByID("239519012529111040"); // bot-room
|
||||||
|
@ -101,6 +103,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
chatchannel = devServer.getChannelByID("248185455508455424"); // minecraft_chat_test
|
chatchannel = devServer.getChannelByID("248185455508455424"); // minecraft_chat_test
|
||||||
officechannel = botchannel; // bot-room
|
officechannel = botchannel; // bot-room
|
||||||
coffeechannel = botchannel; // bot-room
|
coffeechannel = botchannel; // bot-room
|
||||||
|
updatechannel = botchannel;
|
||||||
dc.changeStatus(Status.game("testing"));
|
dc.changeStatus(Status.game("testing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +231,8 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (TBMCCoreAPI.IsTestServer() && channel == chatchannel)
|
||||||
|
MCChatListener.resetLastMessage();
|
||||||
final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel
|
final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel
|
||||||
? "*The following message is from a test server*\n" + message : message;
|
? "*The following message is from a test server*\n" + message : message;
|
||||||
return embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false);
|
return embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
|
||||||
new DiscordSender(null,
|
new DiscordSender(null,
|
||||||
TBMCCoreAPI.IsTestServer() //
|
TBMCCoreAPI.IsTestServer() //
|
||||||
? DiscordPlugin.chatchannel //
|
? DiscordPlugin.chatchannel //
|
||||||
: DiscordPlugin.coffeechannel),
|
: DiscordPlugin.updatechannel),
|
||||||
branch)
|
branch)
|
||||||
&& (!TBMCCoreAPI.IsTestServer() || !branch.equals("master")))
|
&& (!TBMCCoreAPI.IsTestServer() || !branch.equals("master")))
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -39,10 +39,6 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
if (lastmessage == null || lastmessage.isDeleted()
|
if (lastmessage == null || lastmessage.isDeleted()
|
||||||
|| !authorPlayer.equals(lastmessage.getEmbedded().get(0).getAuthor().getName())
|
|| !authorPlayer.equals(lastmessage.getEmbedded().get(0).getAuthor().getName())
|
||||||
|| lastmsgtime / 1000000000f < nanoTime / 1000000000f - 120) {
|
|| lastmsgtime / 1000000000f < nanoTime / 1000000000f - 120) {
|
||||||
/*System.out.println("lastmsgtime: " + lastmsgtime);
|
|
||||||
System.out.println("Current: " + nanoTime);
|
|
||||||
System.out.println("2 mins before: " + (nanoTime - 120 * 1000000000));
|
|
||||||
System.out.println("Diff: " + (nanoTime - (nanoTime - 120 * 1000000000)));*/
|
|
||||||
lastmessage = DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, "", embedObject);
|
lastmessage = DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, "", embedObject);
|
||||||
lastmsgtime = nanoTime;
|
lastmsgtime = nanoTime;
|
||||||
} else
|
} else
|
||||||
|
@ -65,15 +61,19 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
public static final HashMap<String, DiscordSender> UnconnectedSenders = new HashMap<>();
|
public static final HashMap<String, DiscordSender> UnconnectedSenders = new HashMap<>();
|
||||||
public static final HashMap<String, DiscordPlayerSender> ConnectedSenders = new HashMap<>();
|
public static final HashMap<String, DiscordPlayerSender> ConnectedSenders = new HashMap<>();
|
||||||
|
|
||||||
|
public static void resetLastMessage() {
|
||||||
|
lastmessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override // Discord
|
@Override // Discord
|
||||||
public void handle(MessageReceivedEvent event) {
|
public void handle(MessageReceivedEvent event) {
|
||||||
final IUser author = event.getMessage().getAuthor();
|
final IUser author = event.getMessage().getAuthor();
|
||||||
if (author.isBot())
|
|
||||||
return;
|
|
||||||
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())
|
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())
|
||||||
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
||||||
return;
|
return;
|
||||||
lastmessage = null;
|
lastmessage = null;
|
||||||
|
if (author.isBot())
|
||||||
|
return;
|
||||||
if (CommandListener.runCommand(event.getMessage(), true))
|
if (CommandListener.runCommand(event.getMessage(), true))
|
||||||
return;
|
return;
|
||||||
String dmessage = event.getMessage().getContent();
|
String dmessage = event.getMessage().getContent();
|
||||||
|
|
Loading…
Reference in a new issue