Moppletop's September Bug Sprint (#214)

* Earth Cost issue

* Instances of "Tip" to "Thank"

* PC-930

Fix an infinite loop when the game ends.

* PC-959

Fixes an issue where people could spam drop grenades.

* PC-668

Cosmetic Set bonuses no longer carry into MS games

* Changes metal's passive

Metal's passive is now that it gains 0.5 hearts per armor piece. This
avoids the problem of being unkillable
This commit is contained in:
Sam 2016-09-28 02:11:49 +01:00 committed by Shaun Bennett
parent b35d933e56
commit c4e36b2269
6 changed files with 95 additions and 51 deletions

View File

@ -62,7 +62,7 @@ public class GameBoosterManager extends MiniPlugin
_boosterManager.getBoosterThankManager().addTip(player, active, result -> { _boosterManager.getBoosterThankManager().addTip(player, active, result -> {
if (result == TipAddResult.SUCCESS) if (result == TipAddResult.SUCCESS)
{ {
UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got " UtilPlayer.message(player, F.main("Thank", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got "
+ F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!"); + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!");
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
} else } else

View File

@ -155,6 +155,8 @@ public class Build extends Game
protected UUID _winnerUUID = null; protected UUID _winnerUUID = null;
private boolean _calculatedPlaces;
public Build(ArcadeManager manager) public Build(ArcadeManager manager)
{ {
this(manager, GameType.Build); this(manager, GameType.Build);
@ -584,6 +586,15 @@ public class Build extends Game
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestPoints)); _scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestPoints));
} }
//This is to prevent an obscure bug where apparently the game can get stuck in an infinite loop at the end of the game.
//The only solution I see is to check if scores have been previously calculated thus preventing a loop happening here.
if (_calculatedPlaces)
{
return;
}
_calculatedPlaces = true;
//Announce //Announce
AnnounceEnd(places); AnnounceEnd(places);

View File

@ -37,6 +37,7 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
@ -44,10 +45,11 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -60,8 +62,8 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.minestrike.GunModule.RoundOverEvent; import nautilus.game.arcade.game.games.minestrike.GunModule.RoundOverEvent;
import nautilus.game.arcade.game.games.minestrike.data.Bomb; import nautilus.game.arcade.game.games.minestrike.data.Bomb;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
@ -935,6 +937,9 @@ public class Minestrike extends TeamGame
UtilTextMiddle.display(C.cGreen + "$" + _shopManager.getMoney(player), "Open your Inventory to buy new equipment", 10, 120, 10, player); UtilTextMiddle.display(C.cGreen + "$" + _shopManager.getMoney(player), "Open your Inventory to buy new equipment", 10, 120, 10, player);
} }
//Reset grenades
_shopManager.resetGrenades();
//Update Scoreboard Teams //Update Scoreboard Teams
for (GameTeam team : GetTeamList()) for (GameTeam team : GetTeamList())
for (Player teamMember : team.GetPlayers(true)) for (Player teamMember : team.GetPlayers(true))
@ -1048,6 +1053,8 @@ public class Minestrike extends TeamGame
return; return;
} }
Manager.getCosmeticManager().getGadgetManager().getActive(event.getPlayer(), GadgetType.COSTUME).disable(event.getPlayer());
//Target Team //Target Team
GameTeam targetTeam = null; GameTeam targetTeam = null;
if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size()) if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size())

View File

@ -2,6 +2,16 @@ package nautilus.game.arcade.game.games.minestrike;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -18,27 +28,29 @@ import nautilus.game.arcade.game.games.minestrike.items.equipment.DefusalKit;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Helmet; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Helmet;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Kevlar; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Kevlar;
import nautilus.game.arcade.game.games.minestrike.items.grenades.*; import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Incendiary;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats;
import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
public class ShopManager public class ShopManager
{ {
private static final int MAX_GRENADES_PER_ROUND = 4;
private Minestrike Host; private Minestrike Host;
private HashMap<Player, HashMap<Integer, StrikeItem>> _shop = new HashMap<Player, HashMap<Integer, StrikeItem>>(); private HashMap<Player, HashMap<Integer, StrikeItem>> _shop = new HashMap<Player, HashMap<Integer, StrikeItem>>();
private HashMap<Player, Integer> _money = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _money = new HashMap<Player, Integer>();
private HashSet<Player> _inShop = new HashSet<Player>(); private HashSet<Player> _inShop = new HashSet<Player>();
private Map<UUID, Integer> _boughtGrenades = new HashMap<>();
public ShopManager(Minestrike minestrike) public ShopManager(Minestrike minestrike)
{ {
Host = minestrike; Host = minestrike;
@ -227,6 +239,15 @@ public class ShopManager
else if (item instanceof Grenade) else if (item instanceof Grenade)
{ {
Grenade grenade = (Grenade)item; Grenade grenade = (Grenade)item;
UUID key = player.getUniqueId();
_boughtGrenades.putIfAbsent(key, 0);
if (_boughtGrenades.get(key) > MAX_GRENADES_PER_ROUND)
{
player.sendMessage(F.main("Game", "You have purchased the maximum amount of grenades!"));
return;
}
if (!grenade.giveToPlayer(player, true)) if (!grenade.giveToPlayer(player, true))
{ {
@ -234,6 +255,7 @@ public class ShopManager
return; return;
} }
_boughtGrenades.put(key, _boughtGrenades.get(key) + 1);
Host.getGunModule().registerGrenade(grenade, player); Host.getGunModule().registerGrenade(grenade, player);
} }
@ -322,4 +344,9 @@ public class ShopManager
} }
} }
} }
public void resetGrenades()
{
_boughtGrenades.clear();
}
} }

View File

@ -31,7 +31,7 @@ public class KitMetal extends ProgressingKit
"Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".", "Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".",
"", "",
"For each piece of metal armor you wear you gain", "For each piece of metal armor you wear you gain",
"a " + C.cGreen + 7.5 + C.cWhite + "% damage resistance.", "an additional " + C.cGreen + "0.5" + C.cWhite + " hearts.",
}; };
private static final String MAGNET = "Magnet"; private static final String MAGNET = "Magnet";

View File

@ -29,7 +29,8 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.effects.LineParticle; import mineplex.core.common.util.particles.effects.LineParticle;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skywars.TeamSkywars; import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
@ -43,8 +44,7 @@ public class PerkMagnetism extends Perk
public PerkMagnetism(long cooldown, int range, double magnitudeFactor) public PerkMagnetism(long cooldown, int range, double magnitudeFactor)
{ {
super("Magnetism", new String[] { super("Magnetism", new String[] {});
});
_cooldown = cooldown; _cooldown = cooldown;
_range = range; _range = range;
@ -52,23 +52,24 @@ public class PerkMagnetism extends Perk
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onCustomDamage(CustomDamageEvent event) public void onUpdate(UpdateEvent event)
{ {
if (!(event.GetDamageeEntity() instanceof Player)) if (event.getType() != UpdateType.SEC)
{ {
return; return;
} }
Player player = event.GetDamageePlayer(); for (Player player : UtilServer.getPlayers())
if (!hasPerk(player))
{ {
return; if (!hasPerk(player) || UtilPlayer.isSpectator(player))
{
continue;
}
int magnitude = getAmountOfMetalArmor(player);
player.setMaxHealth(20 + magnitude);
} }
int magnitude = getAmountOfMetalArmor(player);
event.AddMod(GetName(), event.GetDamage() * (magnitude * -0.05));
} }
@EventHandler @EventHandler
@ -129,7 +130,8 @@ public class PerkMagnetism extends Perk
Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName());
LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), null, ParticleType.FIREWORKS_SPARK, UtilServer
.getPlayers());
while (!lineParticle.update()) while (!lineParticle.update())
{ {
@ -251,10 +253,7 @@ public class PerkMagnetism extends Perk
{ {
if (UtilItem.isIronProduct(itemStack) || UtilItem.isGoldProduct(itemStack) || UtilItem.isChainmailProduct(itemStack)) if (UtilItem.isIronProduct(itemStack) || UtilItem.isGoldProduct(itemStack) || UtilItem.isChainmailProduct(itemStack))
{ {
if (UtilItem.isArmor(itemStack)) magnitude++;
{
magnitude++;
}
} }
} }