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