Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Don't working anymore | Windows 11 #60

Open
douzooo opened this issue Dec 16, 2021 · 2 comments
Open

Don't working anymore | Windows 11 #60

douzooo opened this issue Dec 16, 2021 · 2 comments

Comments

@douzooo
Copy link

douzooo commented Dec 16, 2021

Hello. I am using the new version and i am on windows 11
but oftenen my discord rpc dont show up. I also use the example

package at.eruxmod.utils.application.discord;

import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;

import javax.swing.*;
import java.awt.*;
import java.util.Scanner;

public class DiscordRP {

    private static boolean ready = false;

    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFrame frame = new JFrame("Test");
        JLabel text = new JLabel("Now goto Discord and set your active game to: '" + frame.getTitle() + "'");
        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int width = gd.getDisplayMode().getWidth();
        int height = gd.getDisplayMode().getHeight();

        frame.getContentPane().setLayout(new FlowLayout());
        frame.getContentPane().setBackground(new Color(114, 137, 218));
        frame.getContentPane().add(text, SwingConstants.CENTER);

        frame.setResizable(true);
        frame.setSize(width/4, height/4);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        frame.setVisible(true);

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            System.out.println("Closing Discord hook.");
            DiscordRPC.discordShutdown();
        }));

        initDiscord();

        int score = 0;
        System.out.println("Running callbacks...");

        while (true) {
            DiscordRPC.discordRunCallbacks();

            if(!ready)
                continue;

            System.out.print("> ");
            Scanner in = new Scanner(System.in);
            String input = in.nextLine();

            if (!input.equalsIgnoreCase("shutdown")) {
                if (input.equalsIgnoreCase("test")) {
                    score++;
                    DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("Score: ");
                    presence.setDetails("Running Test");
                    DiscordRPC.discordUpdatePresence(presence.build());
                } else {
                    System.out.println("Unknown Command: " +
                            "\n\nAvailable Commands:" +
                            "\ntest - Test.\nshutdown - End this test peacefully.");
                }
            } else {
                frame.dispose();
                System.exit(0);
            }
        }
    }

    private static void initDiscord() {
        DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
            DiscordRP.ready = true;
            System.out.println("Welcome " + user.username + "#" + user.discriminator + ".");
            DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("Score: ");
            presence.setDetails("Running Test");
            DiscordRPC.discordUpdatePresence(presence.build());
        }).build();
        DiscordRPC.discordInitialize("415885161457123338", handlers, false);
        DiscordRPC.discordRegister("415885161457123338", "");
    }


}

No Errors

@tristancamejo
Copy link

Many of my beta testers use Windows 11 and their RPC have no problems.

@Euro-pol
Copy link

config issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants