Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b20a6e342 | ||
|
|
cdc692d6d2 |
@@ -92,6 +92,11 @@ public class VoteConfig {
|
||||
return cfg().getBoolean("voteparty.broadcast.enabled", true);
|
||||
}
|
||||
|
||||
/** N'annonce la progression que tous les N votes (1 = a chaque vote). */
|
||||
public int getVotePartyBroadcastEvery() {
|
||||
return cfg().getInt("voteparty.broadcast.every", 10);
|
||||
}
|
||||
|
||||
public String getVotePartyProgressMessage() {
|
||||
return colorize(cfg().getString("voteparty.broadcast.progress-message",
|
||||
"&b[Vote] &f%current%&7/&f%required% &fvotes avant le prochain VoteParty !"));
|
||||
|
||||
@@ -47,10 +47,14 @@ public class VoteParty {
|
||||
public void addVotes(int amount) {
|
||||
int required = config.getVotePartyVotesRequired();
|
||||
int updated = currentVotes.addAndGet(amount);
|
||||
int shown = Math.min(updated, required);
|
||||
|
||||
if (config.isVotePartyBroadcastEnabled()) {
|
||||
// N'annonce la progression que tous les N votes (config), plus le dernier avant le
|
||||
// declenchement, pour eviter de spam le chat a chaque vote individuel.
|
||||
int every = Math.max(1, config.getVotePartyBroadcastEvery());
|
||||
if (config.isVotePartyBroadcastEnabled() && (shown % every == 0 || shown >= required)) {
|
||||
Bukkit.broadcastMessage(config.getVotePartyProgressMessage()
|
||||
.replace("%current%", String.valueOf(Math.min(updated, required)))
|
||||
.replace("%current%", String.valueOf(shown))
|
||||
.replace("%required%", String.valueOf(required)));
|
||||
}
|
||||
|
||||
@@ -62,14 +66,25 @@ public class VoteParty {
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Commands without %player% run once (e.g. a crate plugin's own "give to everyone"
|
||||
* command). Commands containing %player% are dispatched once per online player, since
|
||||
* VoteParty rewards the whole server rather than a single voter.
|
||||
*/
|
||||
private void trigger() {
|
||||
if (config.isVotePartyBroadcastEnabled()) {
|
||||
Bukkit.broadcastMessage(config.getVotePartyTriggeredMessage());
|
||||
}
|
||||
for (String command : config.getVotePartyCommands()) {
|
||||
if (command.contains("%player%")) {
|
||||
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", player.getName()));
|
||||
}
|
||||
} else {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentVotes() {
|
||||
return currentVotes.get();
|
||||
|
||||
@@ -44,6 +44,10 @@ voteparty:
|
||||
- "goldencrates broadcast_give vote_key 1"
|
||||
broadcast:
|
||||
enabled: true
|
||||
# N'annonce la progression que tous les N votes (10 = 1 message toutes les 10 votes),
|
||||
# plus systematiquement au dernier vote avant le declenchement. Mettre a 1 pour annoncer
|
||||
# a chaque vote.
|
||||
every: 10
|
||||
progress-message: "&b[Vote] &f%current%&7/&f%required% &fvotes avant le prochain VoteParty !"
|
||||
triggered-message: "&a[Vote] &fVoteParty declenche ! Profitez des recompenses !"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user