Server:JavaCord: Allow Displaying PlayerCount Or Server Website

This commit is contained in:
Dark98
2021-10-06 02:46:48 +01:00
parent ab3b1e9731
commit a693615e2e
3 changed files with 10 additions and 2 deletions
@@ -239,7 +239,9 @@ public class GameEngine {
if(GameConstants.WEBSITE_TOTAL_CHARACTERS_INTEGRATION) {
RegisteredAccsWebsite.addUpdateRegisteredUsersTask();
}
DiscordActivity.updateActivity();
if(DiscordActivity.playerCount) {
DiscordActivity.updateActivity();
}
if (System.currentTimeMillis() - lastMassSave > 300000) {
for (Player p : PlayerHandler.players) {
if (p == null) {
@@ -4,6 +4,7 @@ import com.rs2.game.players.PlayerHandler;
public class DiscordActivity {
public static Boolean playerCount = false;
private static int count = 50;
public static void updateActivity() {
@@ -1,5 +1,6 @@
package com.rs2.integrations.discord;
import com.rs2.GameConstants;
import org.javacord.api.DiscordApi;
import org.javacord.api.DiscordApiBuilder;
import org.javacord.api.entity.channel.TextChannel;
@@ -15,7 +16,7 @@ import java.io.IOException;
public class JavaCord {
public static String serverName = "2006-ReBotted";
public static String serverName = GameConstants.SERVER_NAME;
public static String token;
public static DiscordApi api = null;
@@ -33,11 +34,15 @@ public class JavaCord {
api.addListener(new Players());
api.addListener(new Vote());
api.addListener(new Website());
if(!DiscordActivity.playerCount) {
api.updateActivity(GameConstants.WEBSITE_LINK);
}
api.addMessageCreateListener(event -> {
if (event.getMessageContent().startsWith("::movehome")) {
if (event.getMessageAuthor().isServerAdmin()) {
System.out.println("perms");
event.getChannel().sendMessage("perms");
} else {
event.getChannel().sendMessage("You do not have permission to preform this command");
}