Full house cooldown, reset last msg in PM
Plus test account enforced
This commit is contained in:
parent
6d40949ddd
commit
e4382bbcd2
3 changed files with 34 additions and 9 deletions
|
@ -136,6 +136,13 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sent = true;
|
sent = true;
|
||||||
|
if (TBMCCoreAPI.IsTestServer() && !dc.getOurUser().getName().toLowerCase().contains("test")) {
|
||||||
|
TBMCCoreAPI.SendException(
|
||||||
|
"Won't load because we're in testing mode and not using the separate account.",
|
||||||
|
new Exception(
|
||||||
|
"The plugin refuses to load until you change the token to the testing account."));
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 0, 10);
|
}, 0, 10);
|
||||||
for (IListener<?> listener : CommandListener.getListeners())
|
for (IListener<?> listener : CommandListener.getListeners())
|
||||||
|
@ -184,7 +191,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
stop = true;
|
stop = true;
|
||||||
for(val entry : MCChatListener.ConnectedSenders.entrySet())
|
for (val entry : MCChatListener.ConnectedSenders.entrySet())
|
||||||
MCListener.callEventExcluding(new PlayerQuitEvent(entry.getValue(), ""), "ProtocolLib");
|
MCListener.callEventExcluding(new PlayerQuitEvent(entry.getValue(), ""), "ProtocolLib");
|
||||||
getConfig().set("lastannouncementtime", lastannouncementtime);
|
getConfig().set("lastannouncementtime", lastannouncementtime);
|
||||||
getConfig().set("lastseentime", lastseentime);
|
getConfig().set("lastseentime", lastseentime);
|
||||||
|
@ -284,9 +291,9 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
try {
|
try {
|
||||||
if (channel == chatchannel)
|
if (channel == chatchannel)
|
||||||
MCChatListener.resetLastMessage(); // If this is a chat message, it'll be set again
|
MCChatListener.resetLastMessage(); // If this is a chat message, it'll be set again
|
||||||
final String content = TBMCCoreAPI.IsTestServer() && (channel != chatchannel || channel == botroomchannel // Both are the same for testing
|
else if (channel.isPrivate())
|
||||||
|| channel.isPrivate()) //
|
MCChatListener.resetLastMessage(channel);
|
||||||
? "*The following message is from a test server*\n" + message : message;
|
final String content = message;
|
||||||
return perform(
|
return perform(
|
||||||
() -> embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false));
|
() -> embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package buttondevteam.discordplugin.listeners;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import buttondevteam.discordplugin.DiscordPlayer;
|
import buttondevteam.discordplugin.DiscordPlayer;
|
||||||
import buttondevteam.discordplugin.DiscordPlugin;
|
import buttondevteam.discordplugin.DiscordPlugin;
|
||||||
|
@ -54,6 +55,8 @@ public class CommandListener {
|
||||||
list.add(i);
|
list.add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long lasttime = 0;
|
||||||
|
|
||||||
public static IListener<?>[] getListeners() {
|
public static IListener<?>[] getListeners() {
|
||||||
return new IListener[] { new IListener<MentionEvent>() {
|
return new IListener[] { new IListener<MentionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,12 +105,15 @@ public class CommandListener {
|
||||||
&& event.getUser().getRolesForGuild(DiscordPlugin.devServer).stream()
|
&& event.getUser().getRolesForGuild(DiscordPlugin.devServer).stream()
|
||||||
.anyMatch(r -> r.getLongID() == devrole.getLongID())
|
.anyMatch(r -> r.getLongID() == devrole.getLongID())
|
||||||
&& DiscordPlugin.devServer.getUsersByRole(devrole).stream()
|
&& DiscordPlugin.devServer.getUsersByRole(devrole).stream()
|
||||||
.noneMatch(u -> u.getPresence().getStatus().equals(StatusType.OFFLINE)))
|
.noneMatch(u -> u.getPresence().getStatus().equals(StatusType.OFFLINE))
|
||||||
|
&& lasttime + 10 < TimeUnit.NANOSECONDS.toHours(System.nanoTime())) {
|
||||||
DiscordPlugin.sendMessageToChannel(DiscordPlugin.devofficechannel, "Full house!",
|
DiscordPlugin.sendMessageToChannel(DiscordPlugin.devofficechannel, "Full house!",
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.withImage(
|
.withImage(
|
||||||
"https://cdn.discordapp.com/attachments/249295547263877121/249687682618359808/poker-hand-full-house-aces-kings-playing-cards-15553791.png")
|
"https://cdn.discordapp.com/attachments/249295547263877121/249687682618359808/poker-hand-full-house-aces-kings-playing-cards-15553791.png")
|
||||||
.build());
|
.build());
|
||||||
|
lasttime = TimeUnit.NANOSECONDS.toHours(System.nanoTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} };
|
} };
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,12 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
: lastmsgdata).message = null;
|
: lastmsgdata).message = null;
|
||||||
} // Don't set the whole object to null, the player and channel information should be preserved
|
} // Don't set the whole object to null, the player and channel information should be preserved
|
||||||
|
|
||||||
|
public static void resetLastMessage(IChannel channel) {
|
||||||
|
for (LastMsgData data : lastmsgPerUser)
|
||||||
|
if (data.channel.getLongID() == channel.getLongID())
|
||||||
|
data.message = null; // Since only private channels are stored, only those will work anyways
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This overload sends it to the global chat.
|
* This overload sends it to the global chat.
|
||||||
*/
|
*/
|
||||||
|
@ -215,7 +221,10 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
&& !(event.getMessage().getChannel().isPrivate() && user.isMinecraftChatEnabled()
|
&& !(event.getMessage().getChannel().isPrivate() && user.isMinecraftChatEnabled()
|
||||||
&& !DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()))
|
&& !DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()))
|
||||||
return;
|
return;
|
||||||
resetLastMessage();
|
if (!event.getMessage().getChannel().isPrivate())
|
||||||
|
resetLastMessage();
|
||||||
|
else
|
||||||
|
resetLastMessage(event.getMessage().getChannel());
|
||||||
lastlist++;
|
lastlist++;
|
||||||
if (author.isBot())
|
if (author.isBot())
|
||||||
return;
|
return;
|
||||||
|
@ -284,9 +293,12 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
val oldch = dsender.getMcchannel();
|
val oldch = dsender.getMcchannel();
|
||||||
if (oldch instanceof ChatRoom)
|
if (oldch instanceof ChatRoom)
|
||||||
((ChatRoom) oldch).leaveRoom(dsender);
|
((ChatRoom) oldch).leaveRoom(dsender);
|
||||||
dsender.setMcchannel(chc);
|
if (!oldch.ID.equals(chc.ID)) {
|
||||||
if (chc instanceof ChatRoom)
|
dsender.setMcchannel(chc);
|
||||||
((ChatRoom) chc).joinRoom(dsender);
|
if (chc instanceof ChatRoom)
|
||||||
|
((ChatRoom) chc).joinRoom(dsender);
|
||||||
|
} else
|
||||||
|
dsender.setMcchannel(Channel.GlobalChat);
|
||||||
dsender.sendMessage("You're now talking in: "
|
dsender.sendMessage("You're now talking in: "
|
||||||
+ DiscordPlugin.sanitizeString(dsender.getMcchannel().DisplayName));
|
+ DiscordPlugin.sanitizeString(dsender.getMcchannel().DisplayName));
|
||||||
} else { // Send single message
|
} else { // Send single message
|
||||||
|
|
Loading…
Reference in a new issue