TNT effect only triggers off self tnt.
This commit is contained in:
parent
7191d48bd0
commit
02270a9d25
@ -151,7 +151,7 @@ public class CosmeticManager extends MiniPlugin
|
||||
_gadgetManager.setActiveItemSlot(i-1);
|
||||
}
|
||||
|
||||
public void setShowInterface(boolean b)
|
||||
public void setActive(boolean b)
|
||||
{
|
||||
_showInterface = b;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.core.gadget.gadgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,10 +17,12 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class ItemTNT extends ItemGadget
|
||||
{
|
||||
//private HashSet<Item> _gems = new HashSet<Item>();
|
||||
private HashSet<TNTPrimed> _tnt = new HashSet<TNTPrimed>();
|
||||
|
||||
public ItemTNT(GadgetManager manager)
|
||||
{
|
||||
@ -37,6 +41,7 @@ public class ItemTNT extends ItemGadget
|
||||
{
|
||||
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
|
||||
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false);
|
||||
_tnt.add(tnt);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill(GetName()) + "."));
|
||||
@ -48,6 +53,9 @@ public class ItemTNT extends ItemGadget
|
||||
if (!(event.getEntity() instanceof TNTPrimed))
|
||||
return;
|
||||
|
||||
if (!_tnt.remove(event.getEntity()))
|
||||
return;
|
||||
|
||||
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 10);
|
||||
for (Player player : players.keySet())
|
||||
{
|
||||
@ -56,46 +64,11 @@ public class ItemTNT extends ItemGadget
|
||||
|
||||
double mult = players.get(player);
|
||||
|
||||
//Drop Gems
|
||||
/*
|
||||
int gemDrop = (int)(10*mult);
|
||||
|
||||
Manager.Manager.GetDonation().RewardGems(null, GetName() + " Hit", player.getName(), -(gemDrop*4));
|
||||
|
||||
for (int i=0 ; i<gemDrop ; i++)
|
||||
{
|
||||
Item gem = player.getLocation().getWorld().dropItem(player.getLocation(), new ItemStack(Material.EMERALD));
|
||||
|
||||
Vector vel = new Vector(Math.random() - 0.5, Math.random(), Math.random() - 0.5);
|
||||
|
||||
UtilAction.velocity(gem, vel, 0.3 + Math.random()*0.3, false, 0, 0, 1, false);
|
||||
|
||||
gem.setPickupDelay(40);
|
||||
|
||||
_gems.add(gem);
|
||||
}
|
||||
*/
|
||||
|
||||
//Knockback
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 3 * mult, false, 0, 0.5 + 2 * mult, 10, true);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@EventHandler
|
||||
public void Pickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_gems.contains(event.getItem()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
Manager.Manager.GetDonation().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), 4);
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||
|
||||
//UtilPlayer.message(event.getPlayer(), C.cGreen + C.Bold + "+4 Gems");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Clean(UpdateEvent event)
|
||||
@ -103,18 +76,17 @@ public class ItemTNT extends ItemGadget
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
Iterator<Item> gemIterator = _gems.iterator();
|
||||
Iterator<TNTPrimed> tntIterator = _tnt.iterator();
|
||||
|
||||
while (gemIterator.hasNext())
|
||||
while (tntIterator.hasNext())
|
||||
{
|
||||
Item gem = gemIterator.next();
|
||||
TNTPrimed tnt = tntIterator.next();
|
||||
|
||||
if (!gem.isValid() || gem.getTicksLived() > 1200)
|
||||
if (!tnt.isValid() || tnt.getTicksLived() > 200)
|
||||
{
|
||||
gem.remove();
|
||||
gemIterator.remove();
|
||||
tnt.remove();
|
||||
tntIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -828,13 +828,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
//Disable
|
||||
if (event.GetState() == GameState.Recruit)
|
||||
{
|
||||
getCosmeticManager().setShowInterface(true);
|
||||
getCosmeticManager().setActive(true);
|
||||
}
|
||||
else if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Loading || event.GetState() == GameState.Dead)
|
||||
{
|
||||
if (getCosmeticManager().isShowingInterface())
|
||||
{
|
||||
getCosmeticManager().setShowInterface(false);
|
||||
getCosmeticManager().setActive(false);
|
||||
getCosmeticManager().disableItemsForGame();
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class GameManager implements Listener
|
||||
{
|
||||
if (Manager.getCosmeticManager().isShowingInterface())
|
||||
{
|
||||
Manager.getCosmeticManager().setShowInterface(false);
|
||||
Manager.getCosmeticManager().setActive(false);
|
||||
Manager.getCosmeticManager().disableItemsForGame();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user