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 -> {
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!");
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
} else

View File

@ -155,6 +155,8 @@ public class Build extends Game
protected UUID _winnerUUID = null;
private boolean _calculatedPlaces;
public Build(ArcadeManager manager)
{
this(manager, GameType.Build);
@ -584,6 +586,15 @@ public class Build extends Game
_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
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.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
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.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
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.recharge.Recharge;
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.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
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.data.Bomb;
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);
}
//Reset grenades
_shopManager.resetGrenades();
//Update Scoreboard Teams
for (GameTeam team : GetTeamList())
for (Player teamMember : team.GetPlayers(true))
@ -1048,6 +1053,8 @@ public class Minestrike extends TeamGame
return;
}
Manager.getCosmeticManager().getGadgetManager().getActive(event.getPlayer(), GadgetType.COSTUME).disable(event.getPlayer());
//Target Team
GameTeam targetTeam = null;
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.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.F;
@ -18,26 +28,28 @@ 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.Helmet;
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.GunStats;
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
{
private static final int MAX_GRENADES_PER_ROUND = 4;
private Minestrike Host;
private HashMap<Player, HashMap<Integer, StrikeItem>> _shop = new HashMap<Player, HashMap<Integer, StrikeItem>>();
private HashMap<Player, Integer> _money = new HashMap<Player, Integer>();
private HashSet<Player> _inShop = new HashSet<Player>();
private Map<UUID, Integer> _boughtGrenades = new HashMap<>();
public ShopManager(Minestrike minestrike)
{
@ -227,13 +239,23 @@ public class ShopManager
else if (item instanceof Grenade)
{
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))
{
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1f);
return;
}
_boughtGrenades.put(key, _boughtGrenades.get(key) + 1);
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 + ".",
"",
"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";

View File

@ -29,46 +29,47 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.effects.LineParticle;
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.games.skywars.TeamSkywars;
import nautilus.game.arcade.kit.Perk;
public class PerkMagnetism extends Perk
{
private long _cooldown;
private int _range;
private double _magnituideFactor;
public PerkMagnetism(long cooldown, int range, double magnitudeFactor)
{
super("Magnetism", new String[] {
});
super("Magnetism", new String[] {});
_cooldown = cooldown;
_range = range;
_magnituideFactor = magnitudeFactor;
}
@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;
}
Player player = event.GetDamageePlayer();
if (!hasPerk(player))
for (Player player : UtilServer.getPlayers())
{
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
@ -102,9 +103,9 @@ public class PerkMagnetism extends Perk
{
return;
}
Game game = Manager.GetGame();
if (game instanceof TeamSkywars)
{
if (game.GetTeam(player).equals(game.GetTeam(target)))
@ -121,22 +122,23 @@ public class PerkMagnetism extends Perk
player.sendMessage(F.main("Game", "They do not have any metal armor on."));
return;
}
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{
return;
}
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())
{
}
Vector vector = UtilAlg.getTrajectory(target, player).multiply((.5 + magnitude / 4) * _magnituideFactor);
UtilAction.velocity(target, vector.setY(Math.max(.6, vector.getY())));
}
@ -188,23 +190,23 @@ public class PerkMagnetism extends Perk
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.IRON_INGOT));
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (!hasPerk(player))
{
return;
}
if (itemStack == null)
{
return;
}
if (itemStack.getType() == Material.REDSTONE_COMPARATOR)
{
event.setCancelled(true);
@ -219,14 +221,14 @@ public class PerkMagnetism extends Perk
{
return;
}
if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_COMPARATOR)
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
@ -242,7 +244,7 @@ public class PerkMagnetism extends Perk
}
}
}
private int getAmountOfMetalArmor(Player player)
{
int magnitude = 0;
@ -251,13 +253,10 @@ public class PerkMagnetism extends Perk
{
if (UtilItem.isIronProduct(itemStack) || UtilItem.isGoldProduct(itemStack) || UtilItem.isChainmailProduct(itemStack))
{
if (UtilItem.isArmor(itemStack))
{
magnitude++;
}
magnitude++;
}
}
return magnitude;
}