Edit mutations and add token and poll options to config
This commit is contained in:
parent
85721f9cd4
commit
5eca38b5a4
|
@ -259,6 +259,7 @@ item.locked = This item cannot be removed from its slot
|
||||||
|
|
||||||
stats.hotbar = {0} kills ({1} streak) {2} deaths {3} K/D
|
stats.hotbar = {0} kills ({1} streak) {2} deaths {3} K/D
|
||||||
|
|
||||||
|
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!
|
||||||
|
|
|
@ -190,42 +190,6 @@ public class PlayerListener implements PluginFacet, Listener {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(user.trial_expires_at() != null) {
|
|
||||||
final Instant expires = TimeUtils.toInstant(user.trial_expires_at());
|
|
||||||
final Instant now = Instant.now();
|
|
||||||
|
|
||||||
if(expires.isAfter(now)) {
|
|
||||||
long days = TimeUtils.daysRoundingUp(Duration.between(now, expires));
|
|
||||||
final String key;
|
|
||||||
if(days <= 1) {
|
|
||||||
key = "trial.remaining.singular";
|
|
||||||
days = 1;
|
|
||||||
} else {
|
|
||||||
key = "trial.remaining.plural";
|
|
||||||
}
|
|
||||||
|
|
||||||
audience.sendMessage(
|
|
||||||
new Component(DARK_PURPLE)
|
|
||||||
.translate(
|
|
||||||
key,
|
|
||||||
new Component(LIGHT_PURPLE).translate("trial.freeTrial"),
|
|
||||||
new Component(days, LIGHT_PURPLE)
|
|
||||||
)
|
|
||||||
.extra(" ")
|
|
||||||
.translate(
|
|
||||||
"trial.details",
|
|
||||||
new Component(LIGHT_PURPLE).translate("trial.joinFull"),
|
|
||||||
new Component(LIGHT_PURPLE).translate("trial.chooseTeam")
|
|
||||||
)
|
|
||||||
.extra(" ")
|
|
||||||
.translate(
|
|
||||||
"trial.upgrade",
|
|
||||||
Links.shopLink()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
audience.sendMessage(new HeaderComponent(
|
audience.sendMessage(new HeaderComponent(
|
||||||
new Component(ChatColor.GREEN)
|
new Component(ChatColor.GREEN)
|
||||||
.translate(
|
.translate(
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class RaindropsListener implements PluginFacet, Listener {
|
||||||
final PlayerId playerId = tc.oc.api.bukkit.users.Users.playerId(player);
|
final PlayerId playerId = tc.oc.api.bukkit.users.Users.playerId(player);
|
||||||
final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
final Objective objective = getOrCreateObjective(scoreboard, player.getName(), "dummy");
|
final Objective objective = getOrCreateObjective(scoreboard, player.getName(), "dummy");
|
||||||
final String raindropsName = ChatColor.AQUA + "Raindrops";
|
final String raindropsName = ChatColor.AQUA + "Droplets";
|
||||||
|
|
||||||
objective.setDisplayName(renderer.renderLegacy(generalFormatter.brandName(), event.getPlayer()));
|
objective.setDisplayName(renderer.renderLegacy(generalFormatter.brandName(), event.getPlayer()));
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,43 @@ public class Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int minimumPlayers() {
|
||||||
|
return getConfiguration().getInt("minimum-players", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Token {
|
||||||
|
public static boolean enabled() {
|
||||||
|
return getConfiguration().getBoolean("tokens.enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double mvpChance() {
|
||||||
|
return getConfiguration().getDouble("tokens.mvp-chance", 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double winningChance() {
|
||||||
|
return getConfiguration().getDouble("tokens.winning-chance", 0.0025);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double losingChance() {
|
||||||
|
return getConfiguration().getDouble("tokens.losing-chance", 0.001);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double setNextTokenChange() {
|
||||||
|
return getConfiguration().getDouble("tokens.sn-chance", 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Poll {
|
||||||
public static Path getPollAbleMapPath() {
|
public static Path getPollAbleMapPath() {
|
||||||
Path pollPath = Paths.get(getConfiguration().getString("poll.maps.path", "default.txt"));
|
Path pollPath = Paths.get(getConfiguration().getString("poll.maps.path", "default.txt"));
|
||||||
if(!pollPath.isAbsolute()) pollPath = PGM.getMatchManager().getPluginDataFolder().resolve(pollPath);
|
if(!pollPath.isAbsolute()) pollPath = PGM.getMatchManager().getPluginDataFolder().resolve(pollPath);
|
||||||
return pollPath;
|
return pollPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int minimumPlayers() {
|
public static boolean enabled() {
|
||||||
return getConfiguration().getInt("minimum-players", 1);
|
return getConfiguration().getBoolean("poll.enabled", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Broadcast {
|
public static class Broadcast {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||||
import tc.oc.commons.core.commands.Commands;
|
import tc.oc.commons.core.commands.Commands;
|
||||||
import tc.oc.commons.core.formatting.StringUtils;
|
import tc.oc.commons.core.formatting.StringUtils;
|
||||||
import tc.oc.commons.core.restart.RestartManager;
|
import tc.oc.commons.core.restart.RestartManager;
|
||||||
|
import tc.oc.pgm.Config;
|
||||||
import tc.oc.pgm.PGM;
|
import tc.oc.pgm.PGM;
|
||||||
import tc.oc.pgm.map.PGMMap;
|
import tc.oc.pgm.map.PGMMap;
|
||||||
import tc.oc.pgm.mutation.Mutation;
|
import tc.oc.pgm.mutation.Mutation;
|
||||||
|
@ -134,6 +135,10 @@ public class PollCommands implements Commands {
|
||||||
return CommandUtils.completeMapName(mapName);
|
return CommandUtils.completeMapName(mapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Config.Poll.enabled()) {
|
||||||
|
throw newCommandException(sender, new TranslatableComponent("poll.disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
if (restartManager.isRestartRequested()) {
|
if (restartManager.isRestartRequested()) {
|
||||||
throw newCommandException(sender, new TranslatableComponent("poll.map.restarting"));
|
throw newCommandException(sender, new TranslatableComponent("poll.map.restarting"));
|
||||||
}
|
}
|
||||||
|
@ -169,6 +174,10 @@ public class PollCommands implements Commands {
|
||||||
@CommandPermissions("poll.mutation")
|
@CommandPermissions("poll.mutation")
|
||||||
public static void pollMutation(CommandContext args, CommandSender sender) throws CommandException {
|
public static void pollMutation(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
|
|
||||||
|
if (!Config.Poll.enabled()) {
|
||||||
|
throw newCommandException(sender, new TranslatableComponent("poll.disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (TokenUtil.getUser(player).mutationtokens() < 1) {
|
if (TokenUtil.getUser(player).mutationtokens() < 1) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||||
import tc.oc.commons.core.chat.Component;
|
import tc.oc.commons.core.chat.Component;
|
||||||
|
import tc.oc.pgm.Config;
|
||||||
import tc.oc.pgm.destroyable.DestroyableContribution;
|
import tc.oc.pgm.destroyable.DestroyableContribution;
|
||||||
import tc.oc.pgm.events.MatchEndEvent;
|
import tc.oc.pgm.events.MatchEndEvent;
|
||||||
import tc.oc.pgm.match.MatchPlayer;
|
import tc.oc.pgm.match.MatchPlayer;
|
||||||
|
@ -73,7 +74,9 @@ public class HighlightListener implements Listener {
|
||||||
if (bestPlayer != null) {
|
if (bestPlayer != null) {
|
||||||
final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD);
|
final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD);
|
||||||
Component subtitle;
|
Component subtitle;
|
||||||
if (Math.random() < 0.05) {
|
|
||||||
|
if (Config.Token.enabled()) {
|
||||||
|
if (Math.random() < Config.Token.mvpChance()) {
|
||||||
String appendMe;
|
String appendMe;
|
||||||
if (Math.random() > 0.25) {
|
if (Math.random() > 0.25) {
|
||||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
TokenUtil.giveMutationTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||||
|
@ -86,6 +89,9 @@ public class HighlightListener implements Listener {
|
||||||
} 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, () -> {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class BreadMutation extends KitMutation {
|
||||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).speed(1,EquipmentSlot.OFF_HAND).speed(1,EquipmentSlot.HAND).name("Very Fast Bread").get()), 3)
|
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).speed(1,EquipmentSlot.OFF_HAND).speed(1,EquipmentSlot.HAND).name("Very Fast Bread").get()), 3)
|
||||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 10).name("Very Hot Bread").get()), 3)
|
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 10).name("Very Hot Bread").get()), 3)
|
||||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 10).name("Very Bouncy Bread").get()), 2)
|
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 10).name("Very Bouncy Bread").get()), 2)
|
||||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 100).name("Insanely Sharp Bread").get()), 1)
|
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 20).name("Insanely Sharp Bread").get()), 1)
|
||||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 100).name("Insanely Bouncy Bread").get()), 1)
|
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 100).name("Insanely Bouncy Bread").get()), 1)
|
||||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 100).name("Insanely Hot Bread").get()), 1)
|
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 100).name("Insanely Hot Bread").get()), 1)
|
||||||
.build();
|
.build();
|
||||||
|
@ -63,7 +63,8 @@ public class BreadMutation extends KitMutation {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerDamage(EntityDamageByEntityEvent event) {
|
public void onPlayerDamage(EntityDamageByEntityEvent event) {
|
||||||
if(event.getDamager() instanceof Player && (((Player) event.getDamager()).getItemInHand()).isSimilar(potionBread)) {
|
if(event.getDamager() instanceof Player && ((((Player) event.getDamager()).getItemInHand()).isSimilar(potionBread)
|
||||||
|
|| (((Player) event.getDamager()).getInventory().getItemInOffHand()).isSimilar(potionBread))) {
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
((LivingEntity)event.getEntity()).addPotionEffect(new PotionEffect(POTIONS.choose(entropy()), 20 * entropy().randomInt(DURATION_RANGE), entropy().randomInt(AMPLIFIER_RANGE)));
|
((LivingEntity)event.getEntity()).addPotionEffect(new PotionEffect(POTIONS.choose(entropy()), 20 * entropy().randomInt(DURATION_RANGE), entropy().randomInt(AMPLIFIER_RANGE)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@ public class ToolsMutation extends KitMutation{
|
||||||
final static FreeItemKit[] TOOLS = new FreeItemKit[] {
|
final static FreeItemKit[] TOOLS = new FreeItemKit[] {
|
||||||
new FreeItemKit(new ItemBuilder(item(Material.DIAMOND_PICKAXE)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Pick").unbreakable(true).get()),
|
new FreeItemKit(new ItemBuilder(item(Material.DIAMOND_PICKAXE)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Pick").unbreakable(true).get()),
|
||||||
new FreeItemKit(new ItemBuilder(item(Material.DIAMOND_AXE)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Axe").unbreakable(true).get()),
|
new FreeItemKit(new ItemBuilder(item(Material.DIAMOND_AXE)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Axe").unbreakable(true).get()),
|
||||||
new FreeItemKit(new ItemBuilder(item(Material.DIAMOND_SPADE)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Shovel").unbreakable(true).get())
|
new FreeItemKit(new ItemBuilder(item(Material.DIAMOND_SPADE)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Shovel").unbreakable(true).get()),
|
||||||
|
new FreeItemKit(new ItemBuilder(item(Material.SHEARS)).enchant(Enchantment.DIG_SPEED, 10).name("Quick Shears").unbreakable(true).get()),
|
||||||
|
new FreeItemKit(new ItemBuilder(item(Material.GLASS)).amount(64).get())
|
||||||
};
|
};
|
||||||
|
|
||||||
final WeakHashMap<MatchPlayer, List<ItemStack>> toolsRemoved;
|
final WeakHashMap<MatchPlayer, List<ItemStack>> toolsRemoved;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class PollableMaps {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadPollableMaps() {
|
public void loadPollableMaps() {
|
||||||
Path filepath = Config.getPollAbleMapPath();
|
Path filepath = Config.Poll.getPollAbleMapPath();
|
||||||
if (filepath == null) return;
|
if (filepath == null) return;
|
||||||
List<String> lines = null;
|
List<String> lines = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package tc.oc.pgm.tokens;
|
package tc.oc.pgm.tokens;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -11,14 +12,20 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import tc.oc.commons.bukkit.event.ObserverKitApplyEvent;
|
import tc.oc.commons.bukkit.event.ObserverKitApplyEvent;
|
||||||
import tc.oc.commons.bukkit.raindrops.RaindropConstants;
|
import tc.oc.commons.bukkit.raindrops.RaindropConstants;
|
||||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||||
|
import tc.oc.commons.core.chat.Component;
|
||||||
import tc.oc.commons.core.util.Comparables;
|
import tc.oc.commons.core.util.Comparables;
|
||||||
|
import tc.oc.pgm.Config;
|
||||||
import tc.oc.pgm.events.MatchEndEvent;
|
import tc.oc.pgm.events.MatchEndEvent;
|
||||||
import tc.oc.pgm.events.ObserverInteractEvent;
|
import tc.oc.pgm.events.ObserverInteractEvent;
|
||||||
|
import tc.oc.pgm.match.Competitor;
|
||||||
import tc.oc.pgm.match.Match;
|
import tc.oc.pgm.match.Match;
|
||||||
import tc.oc.pgm.match.MatchPlayer;
|
import tc.oc.pgm.match.MatchPlayer;
|
||||||
import tc.oc.pgm.teams.Team;
|
import tc.oc.pgm.teams.Team;
|
||||||
import tc.oc.pgm.tokens.gui.MainTokenButton;
|
import tc.oc.pgm.tokens.gui.MainTokenButton;
|
||||||
|
import tc.oc.pgm.victory.VictoryMatchModule;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class TokenListener implements Listener {
|
public class TokenListener implements Listener {
|
||||||
|
|
||||||
|
@ -38,13 +45,22 @@ public class TokenListener implements Listener {
|
||||||
Match match = event.getMatch();
|
Match match = event.getMatch();
|
||||||
//use the same playtime rules as raindrops
|
//use the same playtime rules as raindrops
|
||||||
boolean applyCutoff = Comparables.greaterThan(match.getLength(), RaindropConstants.TEAM_REWARD_CUTOFF);
|
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()) {
|
for(MatchPlayer player : match.getParticipatingPlayers()) {
|
||||||
if(player.getParty() instanceof Team) {
|
if(player.getParty() instanceof Team) {
|
||||||
Team team = (Team) player.getParty();
|
Team team = (Team) player.getParty();
|
||||||
Duration teamTime = team.getCumulativeParticipation(player.getPlayerId());
|
Duration teamTime = team.getCumulativeParticipation(player.getPlayerId());
|
||||||
if(!(applyCutoff && Comparables.lessThan(teamTime, RaindropConstants.TEAM_REWARD_CUTOFF))) {
|
if(!(applyCutoff && Comparables.lessThan(teamTime, RaindropConstants.TEAM_REWARD_CUTOFF))) {
|
||||||
if (Math.random() < 0.005) {
|
Competitor playerTeam = player.getCompetitor();
|
||||||
if (Math.random() > 0.25) {
|
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!");
|
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a Mutation Token!");
|
||||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
TokenUtil.giveMutationTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,6 +68,7 @@ public class TokenListener implements Listener {
|
||||||
TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,15 @@ rotation:
|
||||||
initial-wait: 20000
|
initial-wait: 20000
|
||||||
providers: {}
|
providers: {}
|
||||||
|
|
||||||
|
tokens:
|
||||||
|
enabled: true
|
||||||
|
mvp-chance: 0.03
|
||||||
|
winning-chance: 0.0025
|
||||||
|
losing-chance: 0.001
|
||||||
|
sn-chance: 0.25
|
||||||
|
|
||||||
poll:
|
poll:
|
||||||
|
enabled: true
|
||||||
maps:
|
maps:
|
||||||
path:
|
path:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue