#Hi. Im having this error where when I

1 messages · Page 1 of 1 (latest)

rugged tree
#

.

desert breach
#
  1. newlines please
#
  1. 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

rugged tree
#

a seperate java class for each command?

desert breach
#

a separate java class for the clock.

rugged tree
#

so for example, i have the commands in one class and the bossbar in another.

desert breach
#

mhm

rugged tree
#

alr thanks

#

ill try that

rugged tree
#

The error appears when trying to run any 4 of the commands:
/startclock
/pauseclock
/resumeclock
/final

desert breach
#

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

rugged tree
desert breach
#

do you know what import static does

rugged tree
#

it imports a static variable from another class from my understanding

desert breach
#

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

rugged tree
#

so how can i fix the issue

desert breach
#

separate concerns

#

move the paused thing out of the commands

#

your clock should only know about clock things

rugged tree
#

can i have an example?

desert breach
#

One moment

rugged tree
#

thanks

desert breach
#

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

rugged tree
#

alr thanks