From e0ff1f733b8d813410a18f8f709b7361416747df Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 4 Jul 2018 23:24:32 +0100 Subject: [PATCH] Alex;s PR comments --- .../mineplex/core/mission/MissionContext.java | 9 +++++ .../mineplex/core/mission/MissionManager.java | 40 ++++++++++++------- .../core/mission/MissionPopulator.java | 2 +- .../game/arcade/managers/voting/Vote.java | 23 +---------- .../arcade/managers/voting/VotingManager.java | 31 ++++++++++++++ 5 files changed, 68 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionContext.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionContext.java index 5626d649e..eea11447e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionContext.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionContext.java @@ -17,6 +17,15 @@ public class MissionContext implements Mission private final boolean _eventMission; private final boolean _scaleDownRewards; + /* + To explain what these x and y values mean. + When a mission is generated for a player it picks a random x and y value between the set values. + x is used for the required progress of the mission, so for example "Kill x players". + y is used for as a requirement for progressing the mission and the tracker much provide a y less than or equal to the + y that the mission has set, for example "Kill x players within y seconds of each other". + x is used to calculate the rewards for a mission. + y values do not affect the rewards. + */ private final int _minX, _maxX; private final int _minY, _maxY; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java index 9abc9d9e7..63ea6ad1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java @@ -30,6 +30,7 @@ import org.bukkit.util.Vector; import mineplex.core.MiniDbClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.achievement.leveling.rewards.LevelReward; @@ -61,7 +62,16 @@ public class MissionManager extends MiniDbClientPlugin { VIEW_MISSION_COMMAND, SET_MISSIONS_COMMAND, - DEBUG_MISSION_COMMAND + DEBUG_MISSION_COMMAND, + } + + public enum BonusPerm implements Permission + { + MISSION_BONUS_0_5, + MISSION_BONUS_1, + MISSION_BONUS_1_5, + MISSION_BONUS_2, + MISSION_BONUS_2_5 } private static final int MAX_DAILY = 5; @@ -109,6 +119,11 @@ public class MissionManager extends MiniDbClientPlugin PermissionGroup.PLAYER.setPermission(Perm.VIEW_MISSION_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.SET_MISSIONS_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.DEBUG_MISSION_COMMAND, true, true); + PermissionGroup.ULTRA.setPermission(BonusPerm.MISSION_BONUS_0_5, true, true); + PermissionGroup.HERO.setPermission(BonusPerm.MISSION_BONUS_1, true, true); + PermissionGroup.LEGEND.setPermission(BonusPerm.MISSION_BONUS_1_5, true, true); + PermissionGroup.TITAN.setPermission(BonusPerm.MISSION_BONUS_2, true, true); + PermissionGroup.ETERNAL.setPermission(BonusPerm.MISSION_BONUS_2_5, true, true); if (UtilServer.isTestServer()) { @@ -531,21 +546,18 @@ public class MissionManager extends MiniDbClientPlugin private double getRankBonus(Player player) { - switch (ClientManager.Get(player).getPrimaryGroup()) + CoreClient client = ClientManager.Get(player); + int bonus = 0; + + for (BonusPerm perm : BonusPerm.values()) { - case PLAYER: - return 0; - case ULTRA: - return 0.5; - case HERO: - return 1; - case LEGEND: - return 1.5; - case TITAN: - return 2; - default: - return 2.5; + if (client.hasPermission(perm)) + { + bonus += 0.5; + } } + + return bonus; } public void createNPC(Location location) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java index adaed5e4c..c7b8c96c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java @@ -343,7 +343,7 @@ public class MissionPopulator .build(); MissionContext.newBuilder(manager, 406) - .name("Why Thou") + .name("Why Tho") .description("Craft %s gold shovels") .games(SurvivalGames, SurvivalGamesTeams) .xRange(1, 3) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java index 6e5a87ade..94a586440 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java @@ -10,9 +10,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilServer; import nautilus.game.arcade.ArcadeManager; @@ -38,25 +36,6 @@ public abstract class Vote private static final int VOTE_TIME = 30; - private static double getRankWeight(PermissionGroup group) - { - switch (group) - { - case PLAYER: - return 1.0; - case ULTRA: - return 1.1; - case HERO: - return 1.2; - case LEGEND: - return 1.3; - case TITAN: - return 1.4; - default: - return 1.5; - } - } - private final ArcadeManager _manager; private final String _name; private final ItemStack _itemStack; @@ -88,7 +67,7 @@ public abstract class Vote } else { - _voteData.put(player, new VoteData<>(value, getRankWeight(_manager.GetClients().Get(player).getPrimaryGroup()))); + _voteData.put(player, new VoteData<>(value, _manager.GetGameCreationManager().getVotingManager().getVoteWeight(player))); } _winnerCache = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java index f75430a46..6e666f050 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java @@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import mineplex.core.account.CoreClient; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; @@ -38,6 +39,15 @@ public class VotingManager extends ListenerComponent implements Lifetimed MAP_RATINGS_COMMAND } + public enum WeightPerm implements Permission + { + VOTING_WEIGHT_10, + VOTING_WEIGHT_20, + VOTING_WEIGHT_30, + VOTING_WEIGHT_40, + VOTING_WEIGHT_50, + } + public static final int GAMES_TO_VOTE_ON = 3; public static final int MAPS_TO_VOTE_ON = 5; @@ -63,6 +73,11 @@ public class VotingManager extends ListenerComponent implements Lifetimed private void generatePermissions() { PermissionGroup.ADMIN.setPermission(Perm.MAP_RATINGS_COMMAND, true, true); + PermissionGroup.ULTRA.setPermission(WeightPerm.VOTING_WEIGHT_10, true, true); + PermissionGroup.HERO.setPermission(WeightPerm.VOTING_WEIGHT_20, true, true); + PermissionGroup.LEGEND.setPermission(WeightPerm.VOTING_WEIGHT_30, true, true); + PermissionGroup.TITAN.setPermission(WeightPerm.VOTING_WEIGHT_40, true, true); + PermissionGroup.ETERNAL.setPermission(WeightPerm.VOTING_WEIGHT_50, true, true); } public void callVote(Vote vote) @@ -209,6 +224,22 @@ public class VotingManager extends ListenerComponent implements Lifetimed _manager.runAsync(() -> callback.accept(_repository.getRatings(gameDisplay.getGameId()))); } + public double getVoteWeight(Player player) + { + CoreClient client = _manager.GetClients().Get(player); + double weight = 1; + + for (WeightPerm perm : WeightPerm.values()) + { + if (client.hasPermission(perm)) + { + weight += 0.1; + } + } + + return weight; + } + public Vote getFinishedVote() { return _finishedVote;