-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds real time carbon score alerts for players
Optin alerts, permission required.
- Loading branch information
Showing
8 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.porillo.util; | ||
|
||
import net.porillo.objects.GPlayer; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
public class AlertManager { | ||
|
||
private static AlertManager instance; // single instance | ||
|
||
private Set<UUID> subscribers = new HashSet<>(); | ||
|
||
public void subscribe(UUID uuid) { | ||
this.subscribers.add(uuid); | ||
} | ||
|
||
public void unsubscribe(UUID uuid) { | ||
this.subscribers.remove(uuid); | ||
} | ||
|
||
public boolean isSubscribed(UUID uuid) { | ||
return subscribers.contains(uuid); | ||
} | ||
|
||
public void alert(GPlayer player, String message) { | ||
if (subscribers.contains(player.getUuid())) { | ||
player.sendMsg(message); | ||
} | ||
} | ||
|
||
public static AlertManager getInstance() { | ||
if (instance == null) instance = new AlertManager(); | ||
return instance; | ||
} | ||
} |
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