Skip to content

Commit

Permalink
Reset phase color on new match load
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Herrera <[email protected]>
  • Loading branch information
Pablete1234 committed Feb 23, 2024
1 parent ef5d5a9 commit 811023e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/tc/oc/pgm/db/SettingsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SettingsImpl implements Settings {
}

public static long bitSettings(SettingValue value) {
return 1 << (assertNotNull(value, "setting value is null").ordinal() + 1);
return 1L << (assertNotNull(value, "setting value is null").ordinal() + 1);
}

protected final long getBit() {
Expand Down
20 changes: 12 additions & 8 deletions core/src/main/java/tc/oc/pgm/listeners/MotdListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.event.server.ServerListPingEvent;
import tc.oc.pgm.api.PGM;
import tc.oc.pgm.api.map.MapInfo;
import tc.oc.pgm.api.match.MatchPhase;
import tc.oc.pgm.api.match.event.MatchLoadEvent;
import tc.oc.pgm.api.match.event.MatchPhaseChangeEvent;

Expand Down Expand Up @@ -37,23 +38,26 @@ public void onServerListPing(ServerListPingEvent event) {

@EventHandler
public void onLoad(MatchLoadEvent event) {
phaseColor = getPhaseColor(event.getMatch().getPhase());
mapName = event.getMatch().getMap().getName();
}

@EventHandler(priority = EventPriority.MONITOR)
public void onStateChange(MatchPhaseChangeEvent event) {
switch (event.getNewPhase()) {
phaseColor = getPhaseColor(event.getNewPhase());
}

private ChatColor getPhaseColor(MatchPhase phase) {
switch (phase) {
case STARTING:
phaseColor = ChatColor.YELLOW;
break;
return ChatColor.YELLOW;
case RUNNING:
phaseColor = ChatColor.GREEN;
break;
return ChatColor.GREEN;
case FINISHED:
phaseColor = ChatColor.RED;
break;
return ChatColor.RED;
default:
phaseColor = ChatColor.GRAY;
return ChatColor.GRAY;
}
}

}

0 comments on commit 811023e

Please sign in to comment.