Merge branch 'WitherAssaultUpdate'

This commit is contained in:
Mini-Chiss 2015-07-29 16:37:29 +02:00
commit 71bedbe0fc
2 changed files with 242 additions and 0 deletions

View File

@ -0,0 +1,169 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class PerkWitherCompassScent extends Perk
{
public PerkWitherCompassScent()
{
super("Smell Humans", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with a compass to use " + C.cGreen + "Wither Scent"
});
}
@EventHandler
public void compassRightClick(PlayerInteractEvent event)
{
if(event.isCancelled())
return;
if(!UtilEvent.isAction(event, ActionType.R))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.COMPASS))
return;
if(!Kit.HasKit(event.getPlayer()))
return;
if (!Recharge.Instance.use(event.getPlayer(), GetName(), 30*1000, true, true))
return;
event.setCancelled(true);
Player player = event.getPlayer();
// Code from Wizards changed to WitherGame:
Location loc = player.getEyeLocation().subtract(0, 1, 0);
final ArrayList<Integer[]> colors = new ArrayList<Integer[]>();
for (int x = -1; x <= 1; x++)
{
for (int y = -1; y <= 1; y++)
{
for (int z = -1; z <= 1; z++)
{
colors.add(new Integer[]
{
x, y, z
});
}
}
}
Collections.shuffle(colors);
for (Player enemy : Manager.GetGame().GetPlayers(true))
{
if (enemy == player)
{
continue;
}
if(Manager.GetGame().GetTeam(enemy).GetName().contentEquals("Withers"))
{
continue;
}
final double playerDist = Math.min(7, UtilMath.offset(enemy, player));
final Vector traj = UtilAlg.getTrajectory(player.getLocation(), enemy.getEyeLocation()).multiply(0.1);
final Hologram hologram = new Hologram(Manager.GetGame().getArcadeManager().getHologramManager(), loc.clone().add(0, 0.3, 0)
.add(traj.clone().normalize().multiply(playerDist)), enemy.getName());
hologram.setHologramTarget(HologramTarget.WHITELIST);
hologram.addPlayer(player);
hologram.start();
final Location location = loc.clone();
final Integer[] ints = colors.remove(0);
new BukkitRunnable()
{
int dist;
int tick;
HashMap<Location, Integer> locations = new HashMap<Location, Integer>();
public void run()
{
tick++;
Iterator<Entry<Location, Integer>> itel = locations.entrySet().iterator();
while (itel.hasNext())
{
Entry<Location, Integer> entry = itel.next();
if ((entry.getValue() + tick) % 3 == 0)
{
// Colored redstone dust
UtilParticle.PlayParticle(ParticleType.RED_DUST, entry.getKey(), ints[0], ints[1], ints[2], 1, 0,
ViewDist.LONG, UtilServer.getPlayers());
}
if (entry.getValue() < tick)
{
itel.remove();
}
}
if (dist <= playerDist * 10)
{
for (int a = 0; a < 2; a++)
{
// Colored redstone dust
UtilParticle.PlayParticle(ParticleType.RED_DUST, location, ints[0], ints[1], ints[2], 1, 0,
ViewDist.LONG, UtilServer.getPlayers());
locations.put(location.clone(), tick + 50);
location.add(traj);
dist++;
}
}
else if (locations.isEmpty())
{
hologram.stop();
cancel();
}
}
}.runTaskTimer(Manager.GetGame().getArcadeManager().getPlugin(), 0, 0);
}
player.playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1);
}
}

View File

@ -0,0 +1,73 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherMedicRefill extends Perk
{
private int _max = 0;
private int _time = 0;
public PerkWitherMedicRefill(int timeInSeconds, int max)
{
super("Healing Hands", new String[]
{
C.cGray + "Receive 1 healing bottle every " + timeInSeconds + " seconds if you're inventory is clearned from a bottle.",
});
this._time = timeInSeconds;
this._max = max;
}
@EventHandler
public void bottleRefill(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : UtilServer.getPlayers())
{
if (Manager.isSpectator(player))
continue;
if (!Kit.HasKit(player))
continue;
if (!Manager.GetGame().IsAlive(player))
continue;
if (!Recharge.Instance.use(player, GetName(), _time * 1000, false, false))
continue;
//Add
ItemStack potion = new ItemStack(Material.POTION, 1, (short)16429); // 16422
PotionMeta potionMeta = (PotionMeta)potion.getItemMeta();
potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion");
potion.setItemMeta(potionMeta);
if (UtilInv.contains(player, "Revival Potion", Material.POTION, potion.getData().getData(), _max))
continue;
player.getInventory().addItem(potion);
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
}
}
}