add coinflip command, add mvp to config, prevent maps with too few player slots from being polled
This commit is contained in:
parent
d3dd613b7e
commit
0a994a78e9
|
@ -6,6 +6,7 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
|||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -37,6 +38,22 @@ public class MiscCommands implements Commands {
|
|||
this.identityProvider = identityProvider;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "coinflip" },
|
||||
desc = "Flip a Coin",
|
||||
flags = "b",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("coinflip")
|
||||
public void coinFlip(final CommandContext args, final CommandSender sender) throws CommandException {
|
||||
if (args.hasFlag('b')) {
|
||||
Bukkit.broadcastMessage(ChatColor.AQUA + (Math.random() < 0.5 ? "Heads" : "Tails"));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.AQUA + (Math.random() < 0.5 ? "Heads" : "Tails"));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "sudo" },
|
||||
usage = "<player> [command... (rand|mode|near|color|*)=value]",
|
||||
|
|
|
@ -263,6 +263,7 @@ poll.disabled = Polls are disabled on this server!
|
|||
poll.map.alreadyset = A map has already been set!
|
||||
poll.map.restarting = You cannot set a map because a restart is queued!
|
||||
poll.map.notallowed = You are not allowed to set that map!
|
||||
poll.map.toomanyplayers = There are too many players online to set that map!
|
||||
poll.tutorialmessage = Use {0}/vote [yes|no] {1}to vote
|
||||
|
||||
announce.online = Announced server as online
|
||||
|
|
|
@ -30,6 +30,12 @@ public class Config {
|
|||
return getConfiguration().getInt("minimum-players", 1);
|
||||
}
|
||||
|
||||
public static class MVP {
|
||||
public static boolean enabled() {
|
||||
return getConfiguration().getBoolean("mvp.enabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Token {
|
||||
public static boolean enabled() {
|
||||
return getConfiguration().getBoolean("tokens.enabled", true);
|
||||
|
|
|
@ -160,6 +160,10 @@ public class PollCommands implements Commands {
|
|||
throw newCommandException(sender, new TranslatableComponent("poll.map.notallowed"));
|
||||
}
|
||||
|
||||
if (PGM.get().getServer().getOnlinePlayers().size() * 4 / 5 > nextMap.getDocument().max_players()) {
|
||||
throw newCommandException(sender, new TranslatableComponent("poll.map.toomanyplayers"));
|
||||
}
|
||||
|
||||
startPoll(new PollNextMap(PGM.getPollManager(), Bukkit.getServer(), sender, initiator.getName(), PGM.getMatchManager(), nextMap));
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -27,76 +27,78 @@ public class HighlightListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void matchEnd(MatchEndEvent event) {
|
||||
StatsUserFacet bestPlayerStats = null;
|
||||
MatchPlayer bestPlayer = null;
|
||||
double bestPlayerPoints = 0;
|
||||
if (Config.MVP.enabled()) {
|
||||
StatsUserFacet bestPlayerStats = null;
|
||||
MatchPlayer bestPlayer = null;
|
||||
double bestPlayerPoints = 0;
|
||||
|
||||
if (event.getMatch().getParticipatingPlayers().size() < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MatchPlayer player : event.getMatch().getParticipatingPlayers()) {
|
||||
StatsUserFacet facet = player.getUserContext().facet(StatsUserFacet.class);
|
||||
|
||||
double points = 0;
|
||||
points += facet.matchKills();
|
||||
points -= facet.deaths();
|
||||
points -= facet.teammatesKilled();
|
||||
for (long wool : facet.getWoolCaptureTimes()) {
|
||||
int woolPoints = (int)((wool * 2.25) - 2);
|
||||
points += Math.min(Math.max(woolPoints, 0), 120);
|
||||
if (event.getMatch().getParticipatingPlayers().size() < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (long core : facet.getCoreLeakTimes()) {
|
||||
int corePoints = (int)((core * 2.25) - 2);
|
||||
points += Math.min(Math.max(corePoints, 0), 120);
|
||||
for (MatchPlayer player : event.getMatch().getParticipatingPlayers()) {
|
||||
StatsUserFacet facet = player.getUserContext().facet(StatsUserFacet.class);
|
||||
|
||||
double points = 0;
|
||||
points += facet.matchKills();
|
||||
points -= facet.deaths();
|
||||
points -= facet.teammatesKilled();
|
||||
for (long wool : facet.getWoolCaptureTimes()) {
|
||||
int woolPoints = (int) ((wool * 2.25) - 2);
|
||||
points += Math.min(Math.max(woolPoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long core : facet.getCoreLeakTimes()) {
|
||||
int corePoints = (int) ((core * 2.25) - 2);
|
||||
points += Math.min(Math.max(corePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (DestroyableContribution destroyable : facet.getDestroyableDestroyTimes().keySet()) {
|
||||
int destroyablePoints = (int) ((facet.getDestroyableDestroyTimes().get(destroyable) * 2.25 * destroyable.getPercentage()) - 2);
|
||||
points += Math.min(Math.max(destroyablePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long flag : facet.getFlagCaptureTimes()) {
|
||||
int flagPoints = (int) (flag / 1.75);
|
||||
points += Math.min(Math.max(flagPoints, 0), 120);
|
||||
}
|
||||
|
||||
points += (facet.getBlocksBroken() / 30);
|
||||
|
||||
if (bestPlayerStats == null || points > bestPlayerPoints) {
|
||||
bestPlayerStats = facet;
|
||||
bestPlayer = player;
|
||||
bestPlayerPoints = points;
|
||||
}
|
||||
}
|
||||
|
||||
for (DestroyableContribution destroyable : facet.getDestroyableDestroyTimes().keySet()) {
|
||||
int destroyablePoints = (int)((facet.getDestroyableDestroyTimes().get(destroyable) * 2.25 * destroyable.getPercentage()) - 2);
|
||||
points += Math.min(Math.max(destroyablePoints, 0), 120);
|
||||
}
|
||||
if (bestPlayer != null) {
|
||||
final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD);
|
||||
Component subtitle;
|
||||
|
||||
for (long flag : facet.getFlagCaptureTimes()) {
|
||||
int flagPoints = (int)(flag / 1.75);
|
||||
points += Math.min(Math.max(flagPoints, 0), 120);
|
||||
}
|
||||
|
||||
points += (facet.getBlocksBroken() / 30);
|
||||
|
||||
if (bestPlayerStats == null || points > bestPlayerPoints) {
|
||||
bestPlayerStats = facet;
|
||||
bestPlayer = player;
|
||||
bestPlayerPoints = points;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestPlayer != null) {
|
||||
final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD);
|
||||
Component subtitle;
|
||||
|
||||
if (Config.Token.enabled()) {
|
||||
if (Math.random() < Config.Token.mvpChance()) {
|
||||
String appendMe;
|
||||
if (Math.random() > 0.25) {
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 Mutation Token!";
|
||||
if (Config.Token.enabled()) {
|
||||
if (Math.random() < Config.Token.mvpChance()) {
|
||||
String appendMe;
|
||||
if (Math.random() > 0.25) {
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 Mutation Token!";
|
||||
} else {
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 SetNext Token!";
|
||||
}
|
||||
subtitle = new Component(bestPlayer.getDisplayName() + appendMe);
|
||||
} else {
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 SetNext Token!";
|
||||
subtitle = new Component(bestPlayer.getDisplayName());
|
||||
}
|
||||
subtitle = new Component(bestPlayer.getDisplayName() + appendMe);
|
||||
} else {
|
||||
subtitle = new Component(bestPlayer.getDisplayName());
|
||||
}
|
||||
} else {
|
||||
subtitle = new Component(bestPlayer.getDisplayName());
|
||||
}
|
||||
|
||||
for(MatchPlayer viewer : event.getMatch().getPlayers()) {
|
||||
scheduler.createDelayedTask(100L, () -> {
|
||||
viewer.showTitle(title, subtitle, 0, 60, 60);
|
||||
});
|
||||
for (MatchPlayer viewer : event.getMatch().getPlayers()) {
|
||||
scheduler.createDelayedTask(100L, () -> {
|
||||
viewer.showTitle(title, subtitle, 0, 60, 60);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,33 +42,35 @@ public class TokenListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void handleMatchEndEvent(final MatchEndEvent event) {
|
||||
Match match = event.getMatch();
|
||||
//use the same playtime rules as raindrops
|
||||
boolean applyCutoff = Comparables.greaterThan(match.getLength(), RaindropConstants.TEAM_REWARD_CUTOFF);
|
||||
final Set<Competitor> winners = event.getMatch().needMatchModule(VictoryMatchModule.class).winners();
|
||||
for(MatchPlayer player : match.getParticipatingPlayers()) {
|
||||
if(player.getParty() instanceof Team) {
|
||||
Team team = (Team) player.getParty();
|
||||
Duration teamTime = team.getCumulativeParticipation(player.getPlayerId());
|
||||
if(!(applyCutoff && Comparables.lessThan(teamTime, RaindropConstants.TEAM_REWARD_CUTOFF))) {
|
||||
Competitor playerTeam = player.getCompetitor();
|
||||
assert playerTeam != null;
|
||||
double chance;
|
||||
if (winners.contains(playerTeam)) {
|
||||
chance = Config.Token.winningChance();
|
||||
} else {
|
||||
chance = Config.Token.losingChance();
|
||||
}
|
||||
if (Math.random() < chance) {
|
||||
if (Math.random() > Config.Token.setNextTokenChange()) {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a Mutation Token!");
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
if (Config.Token.enabled()) {
|
||||
Match match = event.getMatch();
|
||||
//use the same playtime rules as raindrops
|
||||
boolean applyCutoff = Comparables.greaterThan(match.getLength(), RaindropConstants.TEAM_REWARD_CUTOFF);
|
||||
final Set<Competitor> winners = event.getMatch().needMatchModule(VictoryMatchModule.class).winners();
|
||||
for (MatchPlayer player : match.getParticipatingPlayers()) {
|
||||
if (player.getParty() instanceof Team) {
|
||||
Team team = (Team) player.getParty();
|
||||
Duration teamTime = team.getCumulativeParticipation(player.getPlayerId());
|
||||
if (!(applyCutoff && Comparables.lessThan(teamTime, RaindropConstants.TEAM_REWARD_CUTOFF))) {
|
||||
Competitor playerTeam = player.getCompetitor();
|
||||
assert playerTeam != null;
|
||||
double chance;
|
||||
if (winners.contains(playerTeam)) {
|
||||
chance = Config.Token.winningChance();
|
||||
} else {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a SetNext Token!");
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
chance = Config.Token.losingChance();
|
||||
}
|
||||
if (Math.random() < chance) {
|
||||
if (Math.random() > Config.Token.setNextTokenChange()) {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a Mutation Token!");
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
} else {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a SetNext Token!");
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,9 @@ tokens:
|
|||
losing-chance: 0.001
|
||||
sn-chance: 0.25
|
||||
|
||||
mvp:
|
||||
enabled: true
|
||||
|
||||
poll:
|
||||
enabled: true
|
||||
maps:
|
||||
|
|
Loading…
Reference in New Issue