Omen
Omen
JCHJava Community | Help. Code. Learn.
Created by Omen on 12/25/2024 in #java-help
The bot isnt responding when i run an message
C:\Users\priya\Desktop\Study\Programs\Omenize Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:136 const invalidToken = new DiscordjsError(ErrorCodes.TokenInvalid); ^ Error [TokenInvalid]: An invalid token was provided. at WebSocketManager.connect (C:\Users\priya\Desktop\Study\Programs\Omenize Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:136:26) at Client.login (C:\Users\priya\Desktop\Study\Programs\Omenize Bot\node_modules\discord.js\src\client\Client.js:228:21) at Object.<anonymous> (C:\Users\priya\Desktop\Study\Programs\Omenize Bot\src\index.js:21:8) at Module._compile (node:internal/modules/cjs/loader:1469:14) at Module._extensions..js (node:internal/modules/cjs/loader:1548:10) at Module.load (node:internal/modules/cjs/loader:1288:32) at Module._load (node:internal/modules/cjs/loader:1104:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'TokenInvalid'
}
at node:internal/main/run_main_module:28:49 {
code: 'TokenInvalid'
}
Node.js v20.18.0 [nodemon] app crashed - waiting for file changes before starting...
13 replies
JCHJava Community | Help. Code. Learn.
Created by Hype_the_Time on 12/12/2024 in #java-help
In Project Annotation Proccessor
public abstract class AbstractDiscordInteractionImplementation<Event extends BBDiscordInteractionEvent<?, EphemeralPolicy>, EphemeralPolicy extends IEphemeralPolicy<BBDiscordInteractionEvent<?, ?>>> {

public abstract class AbstractButtonImplementation extends AbstractDiscordInteractionImplementation<BBButtonInteractionEvent, BBActionInteractionEvent.ActionEphemeralPolicy> {

@DiscordButtonImplementation(id = "ticket-accept-role", name = "Accept", buttonStyle = net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle.SUCCESS)
public abstract class AcceptTicketButtonImplementation extends AbstractButtonImplementation {

generated:

public class AcceptTicketButton extends AbstractButtonImplementation.ButtonInstance {
public AcceptTicketButton(String name, ButtonStyle style) {
super(Button.of(style, "ticket-accept-role", name));
}

public AcceptTicketButton() {
this("Accept", ButtonStyle.SUCCESS);
}

public static class AcceptTicketExecutor extends AcceptTicketButtonImplementation {
@Override
protected void execute(BBButtonInteractionEvent event, Core core) throws OnCooldownException,
SQLException, NoDiscordAvailable, ExternalAPIError, ExecutionException,
InterruptedException, ProfileDoesNotExistException, NoBingoDataException, IOException,
InvalidInputException {
super.execute(event, core);
}
}
}
public abstract class AbstractDiscordInteractionImplementation<Event extends BBDiscordInteractionEvent<?, EphemeralPolicy>, EphemeralPolicy extends IEphemeralPolicy<BBDiscordInteractionEvent<?, ?>>> {

public abstract class AbstractButtonImplementation extends AbstractDiscordInteractionImplementation<BBButtonInteractionEvent, BBActionInteractionEvent.ActionEphemeralPolicy> {

@DiscordButtonImplementation(id = "ticket-accept-role", name = "Accept", buttonStyle = net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle.SUCCESS)
public abstract class AcceptTicketButtonImplementation extends AbstractButtonImplementation {

generated:

public class AcceptTicketButton extends AbstractButtonImplementation.ButtonInstance {
public AcceptTicketButton(String name, ButtonStyle style) {
super(Button.of(style, "ticket-accept-role", name));
}

public AcceptTicketButton() {
this("Accept", ButtonStyle.SUCCESS);
}

public static class AcceptTicketExecutor extends AcceptTicketButtonImplementation {
@Override
protected void execute(BBButtonInteractionEvent event, Core core) throws OnCooldownException,
SQLException, NoDiscordAvailable, ExternalAPIError, ExecutionException,
InterruptedException, ProfileDoesNotExistException, NoBingoDataException, IOException,
InvalidInputException {
super.execute(event, core);
}
}
}
268 replies
JCHJava Community | Help. Code. Learn.
Created by Hype_the_Time on 12/12/2024 in #java-help
In Project Annotation Proccessor
hugging test
268 replies
JCHJava Community | Help. Code. Learn.
Created by Hype_the_Time on 12/12/2024 in #java-help
In Project Annotation Proccessor
2024-12-24T16:24:50.060+0100 [ERROR] [system.err] Unrecognized option : -Dfile.encoding=UTF-8
tasks.named<JavaCompile>("compileJava") {
options.isFork = true
options.forkOptions.apply {
jvmArgs = listOf("-classpath", project.configurations.getByName("ecj").asPath, "org.eclipse.jdt.internal.compiler.batch.Main", "-nowarn")
}
}
tasks.named<JavaCompile>("compileJava") {
options.isFork = true
options.forkOptions.apply {
jvmArgs = listOf("-classpath", project.configurations.getByName("ecj").asPath, "org.eclipse.jdt.internal.compiler.batch.Main", "-nowarn")
}
}
268 replies
JCHJava Community | Help. Code. Learn.
Created by Phloof_boll on 12/8/2024 in #java-help
Am I using the wrong loop or the loop wrong
while (true) {
System.out.println(questions[i]);
if(scanner.next().toLowerCase().equals(answers[i])){
i++;
continue;
} else {
continue;
}
}
while (true) {
System.out.println(questions[i]);
if(scanner.next().toLowerCase().equals(answers[i])){
i++;
continue;
} else {
continue;
}
}
24 replies
JCHJava Community | Help. Code. Learn.
Created by IamMax420 on 12/7/2024 in #java-help
java: cannot find symbol symbol: method builder()
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.36</version> <scope>provided</scope> </dependency> still getting the same error...
157 replies
JCHJava Community | Help. Code. Learn.
Created by john on 11/15/2024 in #java-help
AVL trees
if (restructureNodeOnRemove != null) {
//update heights
updateHeights(restructureNodeOnRemove);
while (restructureNodeOnRemove != null) {
//restructure until tree is balanced
if (!isBalanced(restructureNodeOnRemove)) {
AVLNode z = restructureNodeOnRemove;
AVLNode y = (z.left != null && (z.right == null || z.left.height > z.right.height)) ? z.left : z.right;
AVLNode x = (y.left != null && (y.right == null || y.left.height > y.right.height)) ? y.left : y.right;
restructure(x, y, z);
}
restructureNodeOnRemove = restructureNodeOnRemove.parent;
if(restructureNodeOnRemove!=null){
updateHeights(restructureNodeOnRemove);
}
}

}
if (restructureNodeOnRemove != null) {
//update heights
updateHeights(restructureNodeOnRemove);
while (restructureNodeOnRemove != null) {
//restructure until tree is balanced
if (!isBalanced(restructureNodeOnRemove)) {
AVLNode z = restructureNodeOnRemove;
AVLNode y = (z.left != null && (z.right == null || z.left.height > z.right.height)) ? z.left : z.right;
AVLNode x = (y.left != null && (y.right == null || y.left.height > y.right.height)) ? y.left : y.right;
restructure(x, y, z);
}
restructureNodeOnRemove = restructureNodeOnRemove.parent;
if(restructureNodeOnRemove!=null){
updateHeights(restructureNodeOnRemove);
}
}

}
195 replies
JCHJava Community | Help. Code. Learn.
Created by john on 11/15/2024 in #java-help
AVL trees
updateHeights(restructureNodeOnRemove);
if(restructureNodeOnRemove.parent!=null){
updateHeights(restructureNodeOnRemove.parent);
}
if(restructureNodeOnRemove.parent!=null){
updateHeights(restructureNodeOnRemove.parent);
}
195 replies
JCHJava Community | Help. Code. Learn.
Created by SummerPsycho on 11/15/2024 in #java-help
Flow chart to Java.
""" //name this file program2 or it will not work import java.util.Scanner;
public class program2 {
public static void main(String[] args) {
// Create a Scanner object to read input
Scanner scanner = new Scanner(System.in);

// Prompt the user for an input
System.out.print("Enter an amount of change (0-99): ");
int amount = scanner.nextInt();

// Calculate number of quarters
int quarters = amount / 25;
amount %= 25; // quarters is worth 25

// Calculate number of dimes
int dimes = amount / 10;
amount %= 10; // dimes is worth 10

// Calculate number of nickels
int nickels = amount / 5;
amount %= 5; // nickel is worth 5

//there may be remaining amount, here I add a nickel if there is
if (amount != 0){
nickels += 1;
}

// Display the result
System.out.println("Quarters: " + quarters);
System.out.println("Dimes: " + dimes);
System.out.println("Nickels: " + nickels);
}
}
public class program2 {
public static void main(String[] args) {
// Create a Scanner object to read input
Scanner scanner = new Scanner(System.in);

// Prompt the user for an input
System.out.print("Enter an amount of change (0-99): ");
int amount = scanner.nextInt();

// Calculate number of quarters
int quarters = amount / 25;
amount %= 25; // quarters is worth 25

// Calculate number of dimes
int dimes = amount / 10;
amount %= 10; // dimes is worth 10

// Calculate number of nickels
int nickels = amount / 5;
amount %= 5; // nickel is worth 5

//there may be remaining amount, here I add a nickel if there is
if (amount != 0){
nickels += 1;
}

// Display the result
System.out.println("Quarters: " + quarters);
System.out.println("Dimes: " + dimes);
System.out.println("Nickels: " + nickels);
}
}
"""
8 replies
JCHJava Community | Help. Code. Learn.
Created by john on 11/15/2024 in #java-help
AVL trees
public void restructure(AVLNode x, AVLNode y, AVLNode z){
NodeGroup g = getComponents(x,y,z);
//Getting a NodeGroup object g that for x,y,z returns a,b,c node and subtrees t0,t1,t2 and t3
g.b.left = g.a;
g.b.right = g.c;

g.a.left = g.t0;
g.a.right = g.t1;

g.c.left = g.t2;
g.c.right = g.t3;

if (z.parent != null) {
if (z.parent.left == z) {
z.parent.left = g.b;
} else {
z.parent.right = g.b;
}
} else {
root = g.b;
}
g.b.parent = z.parent;

g.a.parent = g.b;
g.c.parent = g.b;



updateHeights(g.a);
updateHeights(g.c);
updateHeights(g.b);
}
public void restructure(AVLNode x, AVLNode y, AVLNode z){
NodeGroup g = getComponents(x,y,z);
//Getting a NodeGroup object g that for x,y,z returns a,b,c node and subtrees t0,t1,t2 and t3
g.b.left = g.a;
g.b.right = g.c;

g.a.left = g.t0;
g.a.right = g.t1;

g.c.left = g.t2;
g.c.right = g.t3;

if (z.parent != null) {
if (z.parent.left == z) {
z.parent.left = g.b;
} else {
z.parent.right = g.b;
}
} else {
root = g.b;
}
g.b.parent = z.parent;

g.a.parent = g.b;
g.c.parent = g.b;



updateHeights(g.a);
updateHeights(g.c);
updateHeights(g.b);
}
195 replies
JCHJava Community | Help. Code. Learn.
Created by john on 11/15/2024 in #java-help
AVL trees
public boolean insertNode(int key, float value) throws IllegalArgumentException {
if(value < 0 || findByKey(key) != -1f) {
//returning false if node has a key that already exists or value is < 0
return false;
}
AVLNode newNode;
if (root == null){
root = new AVLNode(key, value);
updateHeights(root);
size++;
return true;
}else {
AVLNode current = root;
while (true) {
int cmp = Integer.compare(current.key, key);
if (cmp == 0)
return false;
else if (cmp < 0) {
if (current.right != null)
current = current.right;
else {
newNode = new AVLNode(key, value);
setRight(current,newNode);
updateHeights(newNode);
size++;
break;
}
} else {
if (current.left != null)
current = current.left;
else {
newNode = new AVLNode(key, value);
setLeft(current, newNode); updateHeights(newNode);
size++;
break;
}}}}
AVLNode n = newNode;

while (n != null) {
AVLNode x = n;
if (x.parent != null && x.parent.parent != null && !isBalanced(x.parent.parent)) {
AVLNode z = x.parent.parent;
AVLNode y = x.parent;
restructure(x, y, z);
updateHeights(n);
}else {
n = n.parent;
}
}
return true;
}
public boolean insertNode(int key, float value) throws IllegalArgumentException {
if(value < 0 || findByKey(key) != -1f) {
//returning false if node has a key that already exists or value is < 0
return false;
}
AVLNode newNode;
if (root == null){
root = new AVLNode(key, value);
updateHeights(root);
size++;
return true;
}else {
AVLNode current = root;
while (true) {
int cmp = Integer.compare(current.key, key);
if (cmp == 0)
return false;
else if (cmp < 0) {
if (current.right != null)
current = current.right;
else {
newNode = new AVLNode(key, value);
setRight(current,newNode);
updateHeights(newNode);
size++;
break;
}
} else {
if (current.left != null)
current = current.left;
else {
newNode = new AVLNode(key, value);
setLeft(current, newNode); updateHeights(newNode);
size++;
break;
}}}}
AVLNode n = newNode;

while (n != null) {
AVLNode x = n;
if (x.parent != null && x.parent.parent != null && !isBalanced(x.parent.parent)) {
AVLNode z = x.parent.parent;
AVLNode y = x.parent;
restructure(x, y, z);
updateHeights(n);
}else {
n = n.parent;
}
}
return true;
}
195 replies
JCHJava Community | Help. Code. Learn.
Created by john on 11/15/2024 in #java-help
AVL trees
if (current.height != oldHeight && current.parent != null) {
updateHeights(current.parent);
}
if (current.height != oldHeight && current.parent != null) {
updateHeights(current.parent);
}
195 replies
JCHJava Community | Help. Code. Learn.
Created by Edmon on 11/14/2024 in #java-help
Testing Framework in Java
JUnit
10 replies
JCHJava Community | Help. Code. Learn.
Created by StremesJ on 11/11/2024 in #java-help
Need Help with java ASCII art - can anyone try this and then talk me through it. Please and Thanks:D
Program 4. Seven Segment Display (20%) In the file SevenSegment.jsh, write a method with the signature: void display(int n) that, given a number, displays ASCII art of that number in the style of an electronic “seven segment display”. For example: display(28); -- -- | | | -- -- | | | -- -- You may assume the number is a non-negative Java int. Hints:  Use n % 10 to get the right-most digit of a number. For example, 123456 % 10 == 6.  Use n / 10 to chop off the right-most digit of a number. For example, 123456 / 10 == 12345. To help your program draw the ASCII art, you should use the following method that, given a digit d and a line number n (from 1 to 5), returns a String representing line n of digit d.
String ssd(int d, int n) {
switch ((d*10)+n) {
case 1: case 5: case 21: case 23: case 25: case 31: case 33: case 35:
case 43: case 51: case 53: case 55: case 61: case 63: case 65: case 71:
case 81: case 83: case 85: case 91: case 93: case 95:
return " -- ";
case 24: case 52: case 62:
return "| ";
case 12: case 14: case 22: case 32: case 34: case 44: case 54: case 72:
case 74: case 94:
return " | ";
case 2: case 4: case 42: case 64: case 82: case 84: case 92:
return "| | ";
default: return " ";
}
}
String ssd(int d, int n) {
switch ((d*10)+n) {
case 1: case 5: case 21: case 23: case 25: case 31: case 33: case 35:
case 43: case 51: case 53: case 55: case 61: case 63: case 65: case 71:
case 81: case 83: case 85: case 91: case 93: case 95:
return " -- ";
case 24: case 52: case 62:
return "| ";
case 12: case 14: case 22: case 32: case 34: case 44: case 54: case 72:
case 74: case 94:
return " | ";
case 2: case 4: case 42: case 64: case 82: case 84: case 92:
return "| | ";
default: return " ";
}
}
29 replies
JCHJava Community | Help. Code. Learn.
Created by Akif on 10/30/2024 in #java-help
Module Not Found, when doing "mvn clean install"
open module use.guiFX {

requires javafx.graphics;
requires javafx.fxml;
requires use.core;
requires javafx.controls;
requires javafx.swing;
requires javafx.web;
requires org.kordamp.desktoppanefx.core;
requires use.gui;

exports org.tzi.use.mainFX;
exports org.tzi.use.gui.mainFX;
}
open module use.guiFX {

requires javafx.graphics;
requires javafx.fxml;
requires use.core;
requires javafx.controls;
requires javafx.swing;
requires javafx.web;
requires org.kordamp.desktoppanefx.core;
requires use.gui;

exports org.tzi.use.mainFX;
exports org.tzi.use.gui.mainFX;
}
1275 replies
JCHJava Community | Help. Code. Learn.
Created by Akif on 10/30/2024 in #java-help
Module Not Found, when doing "mvn clean install"
So when i add it like this: :runApp mvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX -Dexec.jvmArgs="%VMARGS%" -Dexec.args="%*" I get following: java.lang.NullPointerException: in (MainWindowFX.java:159) which is this:
if (fSession != null && fSession.hasSystem()) {
fModelBrowser.setModel(fSession.system().model());
}
if (fSession != null && fSession.hasSystem()) {
fModelBrowser.setModel(fSession.system().model());
}
inside MainWindowFX
1275 replies