diff --git a/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties b/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties index ff2a037..972c3a7 100644 --- a/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties +++ b/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties @@ -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 +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! diff --git a/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/PlayerListener.java b/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/PlayerListener.java index e8554b8..f619114 100644 --- a/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/PlayerListener.java +++ b/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/PlayerListener.java @@ -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( new Component(ChatColor.GREEN) .translate( diff --git a/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/RaindropsListener.java b/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/RaindropsListener.java index d4948c1..87952fb 100644 --- a/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/RaindropsListener.java +++ b/Lobby/src/main/java/tc/oc/lobby/bukkit/listeners/RaindropsListener.java @@ -57,7 +57,7 @@ public class RaindropsListener implements PluginFacet, Listener { final PlayerId playerId = tc.oc.api.bukkit.users.Users.playerId(player); final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); 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())); diff --git a/PGM/src/main/java/tc/oc/pgm/Config.java b/PGM/src/main/java/tc/oc/pgm/Config.java index 95b39fd..4085588 100644 --- a/PGM/src/main/java/tc/oc/pgm/Config.java +++ b/PGM/src/main/java/tc/oc/pgm/Config.java @@ -26,16 +26,45 @@ public class Config { } } - public static Path getPollAbleMapPath() { - Path pollPath = Paths.get(getConfiguration().getString("poll.maps.path", "default.txt")); - if(!pollPath.isAbsolute()) pollPath = PGM.getMatchManager().getPluginDataFolder().resolve(pollPath); - return pollPath; - } - 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() { + Path pollPath = Paths.get(getConfiguration().getString("poll.maps.path", "default.txt")); + if(!pollPath.isAbsolute()) pollPath = PGM.getMatchManager().getPluginDataFolder().resolve(pollPath); + return pollPath; + } + + public static boolean enabled() { + return getConfiguration().getBoolean("poll.enabled", true); + } + } + public static class Broadcast { public static boolean title() { return getConfiguration().getBoolean("broadcast.title", true); diff --git a/PGM/src/main/java/tc/oc/pgm/commands/PollCommands.java b/PGM/src/main/java/tc/oc/pgm/commands/PollCommands.java index 71e74b1..cd3a9ce 100644 --- a/PGM/src/main/java/tc/oc/pgm/commands/PollCommands.java +++ b/PGM/src/main/java/tc/oc/pgm/commands/PollCommands.java @@ -15,6 +15,7 @@ import tc.oc.commons.bukkit.tokens.TokenUtil; import tc.oc.commons.core.commands.Commands; import tc.oc.commons.core.formatting.StringUtils; import tc.oc.commons.core.restart.RestartManager; +import tc.oc.pgm.Config; import tc.oc.pgm.PGM; import tc.oc.pgm.map.PGMMap; import tc.oc.pgm.mutation.Mutation; @@ -134,6 +135,10 @@ public class PollCommands implements Commands { return CommandUtils.completeMapName(mapName); } + if (!Config.Poll.enabled()) { + throw newCommandException(sender, new TranslatableComponent("poll.disabled")); + } + if (restartManager.isRestartRequested()) { throw newCommandException(sender, new TranslatableComponent("poll.map.restarting")); } @@ -169,6 +174,10 @@ public class PollCommands implements Commands { @CommandPermissions("poll.mutation") 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) { Player player = (Player) sender; if (TokenUtil.getUser(player).mutationtokens() < 1) { diff --git a/PGM/src/main/java/tc/oc/pgm/highlights/HighlightListener.java b/PGM/src/main/java/tc/oc/pgm/highlights/HighlightListener.java index aa52214..3f1c669 100644 --- a/PGM/src/main/java/tc/oc/pgm/highlights/HighlightListener.java +++ b/PGM/src/main/java/tc/oc/pgm/highlights/HighlightListener.java @@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import tc.oc.commons.bukkit.tokens.TokenUtil; import tc.oc.commons.core.chat.Component; +import tc.oc.pgm.Config; import tc.oc.pgm.destroyable.DestroyableContribution; import tc.oc.pgm.events.MatchEndEvent; import tc.oc.pgm.match.MatchPlayer; @@ -73,16 +74,21 @@ public class HighlightListener implements Listener { if (bestPlayer != null) { final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD); Component subtitle; - if (Math.random() < 0.05) { - 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()); } diff --git a/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java b/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java index 6598489..0388cdb 100644 --- a/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java +++ b/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java @@ -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)).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.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.FIRE_ASPECT, 100).name("Insanely Hot Bread").get()), 1) .build(); @@ -63,7 +63,8 @@ public class BreadMutation extends KitMutation { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) 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) { ((LivingEntity)event.getEntity()).addPotionEffect(new PotionEffect(POTIONS.choose(entropy()), 20 * entropy().randomInt(DURATION_RANGE), entropy().randomInt(AMPLIFIER_RANGE))); } diff --git a/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/ToolsMutation.java b/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/ToolsMutation.java index 2fab0aa..586897a 100644 --- a/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/ToolsMutation.java +++ b/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/ToolsMutation.java @@ -23,7 +23,9 @@ public class ToolsMutation extends KitMutation{ 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_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> toolsRemoved; diff --git a/PGM/src/main/java/tc/oc/pgm/pollablemaps/PollableMaps.java b/PGM/src/main/java/tc/oc/pgm/pollablemaps/PollableMaps.java index 7c5eaee..77242d5 100644 --- a/PGM/src/main/java/tc/oc/pgm/pollablemaps/PollableMaps.java +++ b/PGM/src/main/java/tc/oc/pgm/pollablemaps/PollableMaps.java @@ -27,7 +27,7 @@ public class PollableMaps { } public void loadPollableMaps() { - Path filepath = Config.getPollAbleMapPath(); + Path filepath = Config.Poll.getPollAbleMapPath(); if (filepath == null) return; List lines = null; try { diff --git a/PGM/src/main/java/tc/oc/pgm/tokens/TokenListener.java b/PGM/src/main/java/tc/oc/pgm/tokens/TokenListener.java index abcea45..263f594 100644 --- a/PGM/src/main/java/tc/oc/pgm/tokens/TokenListener.java +++ b/PGM/src/main/java/tc/oc/pgm/tokens/TokenListener.java @@ -1,5 +1,6 @@ package tc.oc.pgm.tokens; +import net.md_5.bungee.api.chat.TranslatableComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; 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.raindrops.RaindropConstants; import tc.oc.commons.bukkit.tokens.TokenUtil; +import tc.oc.commons.core.chat.Component; import tc.oc.commons.core.util.Comparables; +import tc.oc.pgm.Config; import tc.oc.pgm.events.MatchEndEvent; import tc.oc.pgm.events.ObserverInteractEvent; +import tc.oc.pgm.match.Competitor; import tc.oc.pgm.match.Match; import tc.oc.pgm.match.MatchPlayer; import tc.oc.pgm.teams.Team; import tc.oc.pgm.tokens.gui.MainTokenButton; +import tc.oc.pgm.victory.VictoryMatchModule; + import java.time.Duration; +import java.util.Set; public class TokenListener implements Listener { @@ -38,13 +45,22 @@ public class TokenListener implements Listener { Match match = event.getMatch(); //use the same playtime rules as raindrops boolean applyCutoff = Comparables.greaterThan(match.getLength(), RaindropConstants.TEAM_REWARD_CUTOFF); + final Set 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))) { - if (Math.random() < 0.005) { - if (Math.random() > 0.25) { + 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); } else { @@ -52,6 +68,7 @@ public class TokenListener implements Listener { TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1); } } + } } } diff --git a/PGM/src/main/resources/config.yml b/PGM/src/main/resources/config.yml index 5eef205..dca3fed 100644 --- a/PGM/src/main/resources/config.yml +++ b/PGM/src/main/resources/config.yml @@ -84,7 +84,15 @@ rotation: initial-wait: 20000 providers: {} +tokens: + enabled: true + mvp-chance: 0.03 + winning-chance: 0.0025 + losing-chance: 0.001 + sn-chance: 0.25 + poll: + enabled: true maps: path: