Created
December 2, 2017 20:55
-
-
Save ExtraConcentratedJuice/826f37f87954b899f1680df2cddca6a1 to your computer and use it in GitHub Desktop.
presence setter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package extraconcentratedjuice.RichPresenceGUI; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import extraconcentratedjuice.RichPresenceGUI.Main; | |
public class EventListener implements ActionListener | |
{ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
String event = e.getActionCommand(); | |
if (event == "Start") | |
{ | |
Main.panel.start.setEnabled(false); | |
Main.panel.update.setEnabled(true); | |
Main.panel.client_id.setEnabled(false); | |
Main.init_presence(); | |
} | |
else if (event == "Update") | |
{ | |
Main.update_presence(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package extraconcentratedjuice.RichPresenceGUI; | |
import java.awt.EventQueue; | |
import extraconcentratedjuice.RichPresenceGUI.EventListener; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import java.awt.BorderLayout; | |
import javax.swing.JTextField; | |
import javax.swing.JLabel; | |
import javax.swing.SwingConstants; | |
import javax.swing.BoxLayout; | |
import javax.swing.JSpinner; | |
import javax.swing.JButton; | |
import java.awt.event.ActionListener; | |
import java.awt.event.ActionEvent; | |
import javax.swing.JFormattedTextField; | |
import javax.swing.SpinnerNumberModel; | |
public class GUI_Window | |
{ | |
EventListener listener = new EventListener(); | |
private JFrame frame; | |
JTextField client_id; | |
JTextField description; | |
JTextField details; | |
JLabel lblSmallImgKey; | |
JLabel lblLargeImgKey; | |
JTextField sml_key; | |
JTextField lrg_key; | |
JTextField lrg_tool; | |
JTextField sml_tool; | |
JSpinner party_max; | |
JSpinner party_min; | |
JButton start; | |
JButton update; | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) | |
{ | |
EventQueue.invokeLater(new Runnable() | |
{ | |
public void run() | |
{ | |
try | |
{ | |
GUI_Window window = new GUI_Window(); | |
window.frame.setVisible(true); | |
} catch (Exception e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
/** | |
* Create the application. | |
*/ | |
public GUI_Window() | |
{ | |
initialize(); | |
} | |
/** | |
* Initialize the contents of the frame. | |
*/ | |
private void initialize() | |
{ | |
frame = new JFrame("Presence Setter"); | |
frame.setBounds(100, 100, 450, 300); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS)); | |
JPanel panel = new JPanel(); | |
frame.getContentPane().add(panel); | |
panel.setLayout(null); | |
JLabel lblClientId = new JLabel("Client ID"); | |
lblClientId.setBounds(10, 11, 46, 14); | |
panel.add(lblClientId); | |
client_id = new JTextField(); | |
client_id.setBounds(66, 8, 86, 20); | |
panel.add(client_id); | |
client_id.setColumns(10); | |
JLabel lblNewLabel = new JLabel("State"); | |
lblNewLabel.setBounds(10, 36, 46, 14); | |
panel.add(lblNewLabel); | |
description = new JTextField(); | |
description.setBounds(66, 33, 86, 20); | |
panel.add(description); | |
description.setColumns(10); | |
JLabel lblDetails = new JLabel("Details"); | |
lblDetails.setBounds(10, 61, 46, 14); | |
panel.add(lblDetails); | |
details = new JTextField(); | |
details.setBounds(66, 58, 86, 20); | |
panel.add(details); | |
details.setColumns(10); | |
lblSmallImgKey = new JLabel("Small IMG Key"); | |
lblSmallImgKey.setBounds(196, 11, 105, 14); | |
panel.add(lblSmallImgKey); | |
lblLargeImgKey = new JLabel("Large IMG Key"); | |
lblLargeImgKey.setBounds(196, 36, 105, 14); | |
panel.add(lblLargeImgKey); | |
sml_key = new JTextField(); | |
sml_key.setBounds(283, 8, 86, 20); | |
panel.add(sml_key); | |
sml_key.setColumns(10); | |
lrg_key = new JTextField(); | |
lrg_key.setBounds(283, 33, 86, 20); | |
panel.add(lrg_key); | |
lrg_key.setColumns(10); | |
update = new JButton("Update"); | |
update.setEnabled(false); | |
update.addActionListener(listener); | |
update.setBounds(341, 238, 91, 23); | |
panel.add(update); | |
start = new JButton("Start"); | |
start.setBounds(240, 238, 91, 23); | |
start.addActionListener(listener); | |
panel.add(start); | |
party_max = new JSpinner(); | |
party_max.setModel(new SpinnerNumberModel(new Integer(2), null, null, new Integer(1))); | |
party_max.setBounds(76, 119, 46, 18); | |
panel.add(party_max); | |
party_min = new JSpinner(); | |
party_min.setModel(new SpinnerNumberModel(new Integer(1), null, null, new Integer(1))); | |
party_min.setBounds(76, 89, 46, 18); | |
panel.add(party_min); | |
JLabel lblPartyMin = new JLabel("Party Min"); | |
lblPartyMin.setBounds(10, 89, 71, 14); | |
panel.add(lblPartyMin); | |
JLabel lblPartyMax = new JLabel("Party Max"); | |
lblPartyMax.setBounds(10, 121, 61, 14); | |
panel.add(lblPartyMax); | |
JLabel lblTooltipLarge = new JLabel("Tooltip Large"); | |
lblTooltipLarge.setBounds(196, 61, 105, 14); | |
panel.add(lblTooltipLarge); | |
JLabel lblTooltipSmall = new JLabel("Tooltip Small"); | |
lblTooltipSmall.setBounds(196, 92, 105, 14); | |
panel.add(lblTooltipSmall); | |
lrg_tool = new JTextField(); | |
lrg_tool.setBounds(283, 58, 86, 20); | |
panel.add(lrg_tool); | |
lrg_tool.setColumns(10); | |
sml_tool = new JTextField(); | |
sml_tool.setBounds(283, 89, 86, 20); | |
panel.add(sml_tool); | |
sml_tool.setColumns(10); | |
frame.setVisible(true); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package extraconcentratedjuice.RichPresenceGUI; | |
import extraconcentratedjuice.RichPresenceGUI.GUI_Window; | |
import java.time.OffsetDateTime; | |
import com.jagrosh.discordipc.*; | |
import com.jagrosh.discordipc.entities.RichPresence; | |
import com.jagrosh.discordipc.exceptions.NoDiscordClientException; | |
public class Main | |
{ | |
static GUI_Window panel = new GUI_Window(); | |
static IPCClient client; | |
public static void main(String[] args) | |
{ | |
} | |
public static void init_presence() | |
{ | |
client = new IPCClient(Long.parseLong(panel.client_id.getText())); | |
client.setListener(new IPCListener() | |
{ | |
@Override | |
public void onReady(IPCClient client) | |
{ | |
System.out.println((int) panel.party_min.getValue()); | |
System.out.println("Ready!"); | |
client.sendRichPresence(new RichPresence( | |
panel.description.getText(), // App title | |
panel.details.getText(), // App desc. | |
OffsetDateTime.now(), // Timestart | |
null, // Timeend | |
panel.lrg_key.getText(), // large image name | |
panel.lrg_tool.getText(), // large image tooltip | |
panel.sml_key.getText(), // small img name | |
panel.sml_tool.getText(), // small image tooltip | |
"none", // party id (none) | |
(int) panel.party_min.getValue(), // party members | |
(int) panel.party_max.getValue(), //party menbers (max) | |
null, | |
null, | |
null, | |
false | |
)); | |
} | |
}); | |
try | |
{ | |
client.connect(); | |
} catch (NoDiscordClientException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
public static void update_presence() | |
{ | |
client.sendRichPresence(new RichPresence( | |
panel.description.getText(), // App title | |
panel.details.getText(), // App desc. | |
OffsetDateTime.now(), // Timestart | |
null, // Timeend | |
panel.lrg_key.getText(), // large image name | |
panel.lrg_tool.getText(), // large image tooltip | |
panel.sml_key.getText(), // small img name | |
panel.sml_tool.getText(), // small image tooltip | |
"none", // party id (none) | |
(int) panel.party_min.getValue(), // party members | |
(int) panel.party_max.getValue(), //party menbers (max) | |
null, | |
null, | |
null, | |
false | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment