#Hi. Im having this error where when I
1 messages · Page 1 of 1 (latest)
- newlines please
- SRP
separate your concerns
your command should not be doing the clock management
the command can talk to the clock
and tell the clock what to do
and other things can query the clock for what to show
how should I do that
a seperate java class for each command?
a separate java class for the clock.
so for example, i have the commands in one class and the bossbar in another.
mhm
so a bit of an error. Attached is the error from the console.
Here is my commands script:
https://paste.md-5.net/lapiquvogi.java
Here is the bossbar script:
https://paste.md-5.net/rajutomico.java
The error appears when trying to run any 4 of the commands:
/startclock
/pauseclock
/resumeclock
/final
I really think you should learn a bit more about java
I'm seeing the wrong patterns here - singletons and SRP
why are you statically setting plugin
use ?di
im currently learning java. can i just have help with this. ive been having errors for a week or so
do you know what import static does
it imports a static variable from another class from my understanding
why do the commands hold the state of the clock
the clock should have what it needs
the command does not need to know about the clock
so how can i fix the issue
separate concerns
move the paused thing out of the commands
your clock should only know about clock things
can i have an example?
One moment
thanks
public class Countdown {
private int timer;
private boolean isPaused = false;
private BossBar countdownBar = BossBar.bossBar(Component.text("Placeholder Text").color(NamedTextColor.AQUA), 1f, BossBar.Color.WHITE, BossBar.Overlay.NOTCHED_12);
public Countdown(int timer) {
this.timer = timer;
}
public void togglePause() {
this.isPaused = !this.isPaused
}
public void pause() {
this.isPaused = true;
}
public void unpause() {
this.isPaused = false;
}
/**
* Count down by 1 second.
*/
public void countdown() {
if (this.isPaused) return;
this.timer--
}
public void updateBossBar() {
// set the updated stuff here;
}
}
it's up to you whether the task is done by a CountdownManager or Countdown
alr thanks