paintball update

This commit is contained in:
Chiss 2013-11-02 10:09:07 +11:00
parent c72f1337e8
commit 24723cd5e5
14 changed files with 468 additions and 196 deletions

View File

@ -68,12 +68,13 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
CommandCenter.Initialize(this, clientManager);
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);
AntiHack.Initialize(this);
Punish punish = new Punish(this, GetWebServerAddress());
AntiHack.Initialize(this, punish);
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
//Other Modules
new Punish(this, GetWebServerAddress());
Creature creature = new Creature(this);
new MessageManager(this, clientManager);
NpcManager npcManager = new NpcManager(this, creature);

View File

@ -202,7 +202,7 @@ public class ConditionManager extends MiniPlugin
ind.SetCondition(newCon);
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST)
public void ExpireConditions(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)

View File

@ -130,13 +130,15 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_firework = new FireworkHandler();
_fire = new Fire(plugin, conditionManager, damageManager);
_projectileManager = new ProjectileManager(plugin);
_projectileManager = new ProjectileManager(plugin);
/*
_skillFactory = new SkillFactory(plugin, damageManager, this, new CombatManager(plugin), conditionManager, _projectileManager, _blockRestore, _fire, new Movement(plugin), plugin.GetTeleport(), new Energy(plugin), webAddress);
_classManager = new ClassManager(plugin, clientManager, donationManager, _skillFactory, webAddress);
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, new ItemPackFactory(_plugin));
_classCustomBuildShop = new ClassCombatCustomBuildShop(_classShopManager, clientManager, donationManager, webAddress);
*/
_portal = new Portal(plugin);

View File

@ -580,6 +580,9 @@ public abstract class Game implements Listener
public boolean HasKit(Player player, Kit kit)
{
if (!IsAlive(player))
return false;
if (GetKit(player) == null)
return false;

View File

@ -121,10 +121,6 @@ public class Halloween extends SoloGame
_mobs.clear();
_spawns.clear();
_spawns = null;
_mobs = null;
_waves = null;
}
@EventHandler(priority = EventPriority.MONITOR)

View File

@ -178,7 +178,7 @@ public class PumpkinKing extends CreatureBase<Skeleton>
if (event.getType() == UpdateType.TICK)
MinionOrbit();
if (event.getType() == UpdateType.TICK)
if (event.getType() == UpdateType.FASTER)
MinionAttack();
if (event.getType() == UpdateType.TICK)

View File

@ -1,102 +1,402 @@
package nautilus.game.arcade.game.games.paintball;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.paintball.kits.*;
import nautilus.game.arcade.kit.Kit;
public class Paintball extends TeamGame
{
private HashSet<StuntDouble> _doubles = new HashSet<StuntDouble>();
private HashMap<Player, PlayerCopy> _doubles = new HashMap<Player, PlayerCopy>();
private HashSet<Projectile> _water = new HashSet<Projectile>();
public Paintball(ArcadeManager manager)
{
super(manager, GameType.Paintball,
new Kit[]
{
new KitRifle(manager),
new KitMachineGun(manager),
new KitShotgun(manager)
new KitRifle(manager),
new KitMachineGun(manager),
new KitShotgun(manager),
},
new String[]
{
"put put put put put"
"Shoot enemies to paint them",
"Revive/heal with Water Bombs",
"Last team alive wins!"
});
}
/*
@EventHandler
public void CustomTeamGeneration(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
return;
this.GetTeamList().get(0).SetColor(ChatColor.AQUA);
this.GetTeamList().get(0).SetName("Frost");
this.GetTeamList().get(1).SetColor(ChatColor.RED);
this.GetTeamList().get(1).SetName("Nether");
}
*/
@EventHandler
public void RefreshPlayers(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
for (Player player : GetPlayers(true))
for (Player other : GetPlayers(true))
{
other.hidePlayer(player);
other.showPlayer(player);
}
}
@EventHandler
public void HealthRegen(EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED)
event.setCancelled(true);
}
@EventHandler
public void Teleport(PlayerTeleportEvent event)
{
if (event.getCause() == TeleportCause.ENDER_PEARL)
event.setCancelled(true);
}
@EventHandler
public void Paint(ProjectileHitEvent event)
{
if (event.getEntity() instanceof ThrownPotion)
return;
byte color = 3;
if (event.getEntity() instanceof EnderPearl)
color = 6;
color = 14;
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity());
for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet())
{
if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY)
continue;
block.setData(color);
}
if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8);
else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10);
}
@EventHandler
public void DamageOut(CustomDamageEvent event)
public void PlayerQuit(PlayerQuitEvent event)
{
_doubles.remove(event.getPlayer());
}
@EventHandler
public void DamageCancel(CustomDamageEvent event)
{
if (event.GetDamageePlayer() == null)
event.SetCancelled("Not Player");
if (event.GetProjectile() == null)
event.SetCancelled("No Projectile");
}
@EventHandler
public void PaintballDamage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetProjectile() == null)
return;
if (!(event.GetProjectile() instanceof Snowball) && !(event.GetProjectile() instanceof EnderPearl))
return;
//Negate
event.AddMod("Negate", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Paintball", "Paintball", 2, true);
event.AddKnockback("Paintball", 2);
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
event.SetCancelled("PAINTBALLZ");
_doubles.add(new StuntDouble(this, damagee));
if (damagee == null) return;
Player damager = event.GetDamagerPlayer(true);
if (damager == null) return;
//Color
Color color = Color.RED;
if (event.GetProjectile() instanceof Snowball)
color = Color.AQUA;
//Count
int count = 1;
if (GetKit(damager) != null)
{
if (GetKit(damager) instanceof KitRifle)
{
count = 3;
}
}
//Out
if (Color(damagee, color, count))
{
PlayerOut(damagee);
Announce(GetTeam(damagee).GetColor() + damagee.getName() + ChatColor.RESET + " was painted by " +
GetTeam(damager).GetColor() + damager.getName());
}
//Hit Sound
Player player = event.GetDamagerPlayer(true);
if (player != null)
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 3f);
}
public boolean Color(Player player, Color color, int amount)
{
//Get Non-Coloured
ArrayList<ItemStack> nonColored = new ArrayList<ItemStack>();
for (ItemStack stack : player.getInventory().getArmorContents())
{
if (!(stack.getItemMeta() instanceof LeatherArmorMeta))
continue;
LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
if (meta.getColor().equals(Color.WHITE))
nonColored.add(stack);
}
//Color Piece
for (int i=0 ; i<amount ; i++)
{
if (nonColored.isEmpty())
break;
ItemStack armor = nonColored.remove(UtilMath.r(nonColored.size()));
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(color);
armor.setItemMeta(meta);
}
player.setHealth(Math.min(20, Math.max(2, nonColored.size() * 5 + 1)));
return nonColored.isEmpty();
}
public void PlayerOut(Player player)
{
//State
SetPlayerState(player, PlayerState.OUT);
player.setHealth(20);
//Conditions
Manager.GetCondition().Factory().Blind("Hit", player, player, 1.5, 0, false, false, false);
Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false);
//Settings
player.setGameMode(GameMode.CREATIVE);
player.setFlying(true);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer)player).getHandle().m = false;
player.setVelocity(new Vector(0,1.2,0));
_doubles.put(player, new PlayerCopy(this, player));
}
@EventHandler
public void CleanThrow(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!UtilGear.isMat(player.getItemInHand(), Material.POTION))
return;
if (!IsAlive(player))
return;
if (!Recharge.Instance.use(player, "Water Bomb", 500, false))
return;
//Use Stock
UtilInv.remove(player, Material.POTION, (byte)0, 1);
//Start
ThrownPotion potion = player.launchProjectile(ThrownPotion.class);
_water.add(potion);
//Inform
UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill("Water Bomb") + "."));
}
@EventHandler
public void CleanHit(ProjectileHitEvent event)
{
if (!_water.remove(event.getEntity()))
return;
if (event.getEntity().getShooter() == null)
return;
if (!(event.getEntity().getShooter() instanceof Player))
return;
Player thrower = (Player)event.getEntity().getShooter();
GameTeam throwerTeam = GetTeam(thrower);
if (throwerTeam == null) return;
//Revive
Iterator<PlayerCopy> copyIterator = _doubles.values().iterator();
while (copyIterator.hasNext())
{
PlayerCopy copy = copyIterator.next();
GameTeam otherTeam = GetTeam(copy.GetPlayer());
if (otherTeam == null || !otherTeam.equals(throwerTeam))
continue;
if (UtilMath.offset(copy.GetEntity().getLocation().add(0,1,0), event.getEntity().getLocation()) > 3)
continue;
PlayerIn(copy.GetPlayer(), copy.GetEntity());
copyIterator.remove();
AddGems(thrower, 2, "Revived Ally", true);
}
//Clean
for (Player player : GetPlayers(true))
{
GameTeam otherTeam = GetTeam(player);
if (otherTeam == null || !otherTeam.equals(throwerTeam))
continue;
if (UtilMath.offset(player.getLocation().add(0,1,0), event.getEntity().getLocation()) > 3)
continue;
PlayerIn(player, null);
AddGems(thrower, 1, "Healed Ally", true);
}
}
public void PlayerIn(final Player player, final LivingEntity copy)
{
//State
SetPlayerState(player, PlayerState.IN);
player.setHealth(20);
//Teleport
if (copy != null)
{
Location loc = player.getLocation();
loc.setX(copy.getLocation().getX());
loc.setY(copy.getLocation().getY());
loc.setZ(copy.getLocation().getZ());
player.teleport(loc);
}
//Settings
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(false);
((CraftPlayer)player).getHandle().spectating = false;
((CraftPlayer)player).getHandle().m = true;
//Clean Armor
for (ItemStack stack : player.getInventory().getArmorContents())
{
if (!(stack.getItemMeta() instanceof LeatherArmorMeta))
continue;
LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
meta.setColor(Color.WHITE);
stack.setItemMeta(meta);
}
//Inform
UtilPlayer.message(player, F.main("Game", "You have been cleaned!"));
//Delayed Visibility
if (copy != null)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
//Remove Invis
Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null);
//Remove Copy
copy.remove();
}
}, 4);
}
}
}

View File

@ -0,0 +1,50 @@
package nautilus.game.arcade.game.games.paintball;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
public class PlayerCopy
{
private Paintball Host;
private Skeleton _ent;
private Player _owner;
public PlayerCopy(Paintball host, Player owner)
{
Host = host;
_owner = owner;
Host.CreatureAllowOverride = true;
_ent = owner.getWorld().spawn(owner.getLocation(), Skeleton.class);
Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(_ent);
//Armor
_ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents());
_ent.setCustomName(C.cWhite + C.Bold + "OUT " + ChatColor.RESET + host.GetTeam(owner).GetColor() + owner.getName());
_ent.setCustomNameVisible(true);
//Disguise
//DisguisePlayer disguise = new DisguisePlayer(_ent, owner.getName());
//Host.Manager.GetDisguise().disguise(disguise);
}
public LivingEntity GetEntity()
{
return _ent;
}
public Player GetPlayer()
{
return _owner;
}
}

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.F;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
@ -23,7 +23,8 @@ public class KitMachineGun extends Kit
new String[]
{
"Full-automatic paintball gun. " + F.elem("6 Damage")
"Full-automatic paintball gun.",
C.cGold + "4 Hit Kill"
},
new Perk[]
@ -37,7 +38,8 @@ public class KitMachineGun extends Kit
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, "Paintball Machine Gun"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.POTION, (byte)0, 3, "Water Bomb"));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.F;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
@ -23,7 +23,8 @@ public class KitRifle extends Kit
new String[]
{
"Semi-automatic paintball rifle. " + F.elem("12 Damage")
"Semi-automatic paintball rifle.",
C.cGold + "2 Hit Kill"
},
new Perk[]
@ -38,7 +39,8 @@ public class KitRifle extends Kit
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, "Paintball Rifle"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.POTION, (byte)0, 3, "Water Bomb"));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.F;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
@ -23,7 +23,8 @@ public class KitShotgun extends Kit
new String[]
{
"Pump action paintball shotgun. " + F.elem("6 Damage per Pellet")
"Pump action paintball shotgun.",
C.cGold + "4 Hit Kill"
},
new Perk[]
@ -38,8 +39,9 @@ public class KitShotgun extends Kit
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, "Paintball Shotgun"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.POTION, (byte)0, 3, "Water Bomb"));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();
metaHelm.setColor(Color.WHITE);

View File

@ -1,9 +1,6 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EnderPearl;
@ -13,29 +10,45 @@ import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
public class PerkPaintballMachineGun extends Perk
{
private HashSet<Projectile> _balls = new HashSet<Projectile>();
public PerkPaintballMachineGun()
{
super("Rifle", new String[]
super("Machine Gun", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Machine Gun"
C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Machine Gun",
"Experience Bar represents weapon overheating."
});
}
@EventHandler
public void WeaponCooldown(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
{
if (!Kit.HasKit(player))
continue;
if (Recharge.Instance.usable(player, "Cool"))
player.setExp((float)Math.max(0f, player.getExp() - 0.015f));
}
}
@EventHandler
public void Shoot(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
@ -50,75 +63,65 @@ public class PerkPaintballMachineGun extends Perk
if (event.getPlayer().getItemInHand().getType() != Material.DIAMOND_BARDING)
return;
Player player = event.getPlayer();
final Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
GameTeam team = Manager.GetGame().GetTeam(player);
final GameTeam team = Manager.GetGame().GetTeam(player);
if (team == null)
return;
event.setCancelled(true);
ShootPaintball(player, team);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ShootPaintball(player, team);
}
}, 2);
}
public void ShootPaintball(Player player, GameTeam team)
{
//Energy
if (player.getExp() >= 0.97)
return;
player.setExp((float) (player.getExp() + 0.03));
//Shoot
Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
rand.multiply(0.15);
rand.multiply(0.25);
if (team.GetColor() == ChatColor.AQUA)
{
//Projectile proj = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class);
//proj.setVelocity(player.getLocation().getDirection().multiply(1.6).add(rand));
//proj.setShooter(player);
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
_balls.add(proj);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 2f);
}
else
{
Projectile proj = player.launchProjectile(EnderPearl.class);
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
_balls.add(proj);
//Projectile proj = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), EnderPearl.class);
//proj.setVelocity(player.getLocation().getDirection().multiply(1.6).add(rand));
//proj.setShooter(player);
//Projectile proj = player.launchProjectile(EnderPearl.class);
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.75f);
}
//Slow
Manager.GetCondition().Factory().Slow("Firing", player, player, 0.9, 1, false, false, false, false);
Recharge.Instance.useForce(player, "Cool", 250);
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!_balls.contains(event.GetProjectile()))
return;
//Negate
event.AddMod("Negate", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Paintball", "Machine Gun", 8, true);
if (event.GetDamageePlayer() == null)
return;
double r = Math.random();
ItemStack item = null;
if (r > 0.75) item= event.GetDamageePlayer().getInventory().getHelmet();
else if (r > 0.50) item= event.GetDamageePlayer().getInventory().getChestplate();
else if (r > 0.25) item= event.GetDamageePlayer().getInventory().getLeggings();
else item= event.GetDamageePlayer().getInventory().getBoots();
LeatherArmorMeta meta = (LeatherArmorMeta)item.getItemMeta();
//Color
if (event.GetProjectile() instanceof Snowball)
meta.setColor(Color.AQUA);
else
meta.setColor(Color.FUCHSIA);
item.setItemMeta(meta);
}
}
}

View File

@ -1,9 +1,6 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EnderPearl;
@ -13,21 +10,15 @@ import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.recharge.*;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
public class PerkPaintballRifle extends Perk
{
private HashSet<Projectile> _balls = new HashSet<Projectile>();
public PerkPaintballRifle()
{
super("Rifle", new String[]
@ -69,7 +60,7 @@ public class PerkPaintballRifle extends Perk
if (team == null)
return;
if (!Recharge.Instance.use(player, GetName(), 400, true))
if (!Recharge.Instance.use(player, GetName(), 500, false))
return;
event.setCancelled(true);
@ -78,54 +69,18 @@ public class PerkPaintballRifle extends Perk
{
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(2));
_balls.add(proj);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.5f);
}
else
{
Projectile proj = player.launchProjectile(EnderPearl.class);
//Projectile proj = player.launchProjectile(EnderPearl.class);
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(2));
_balls.add(proj);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.2f);
}
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!_balls.contains(event.GetProjectile()))
return;
//Negate
event.AddMod("Negate", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Paintball", "Rifle", 16, true);
if (event.GetDamageePlayer() == null)
return;
double r = Math.random();
ItemStack item = null;
if (r > 0.75) item= event.GetDamageePlayer().getInventory().getHelmet();
else if (r > 0.50) item= event.GetDamageePlayer().getInventory().getChestplate();
else if (r > 0.25) item= event.GetDamageePlayer().getInventory().getLeggings();
else item= event.GetDamageePlayer().getInventory().getBoots();
LeatherArmorMeta meta = (LeatherArmorMeta)item.getItemMeta();
//Color
if (event.GetProjectile() instanceof Snowball)
meta.setColor(Color.AQUA);
else
meta.setColor(Color.FUCHSIA);
item.setItemMeta(meta);
}
}

View File

@ -1,9 +1,6 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EnderPearl;
@ -13,22 +10,17 @@ import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
public class PerkPaintballShotgun extends Perk
{
private HashSet<Projectile> _balls = new HashSet<Projectile>();
public PerkPaintballShotgun()
{
super("Shotgun", new String[]
@ -73,67 +65,31 @@ public class PerkPaintballShotgun extends Perk
event.setCancelled(true);
if (!Recharge.Instance.use(player, GetName(), 1000, true))
if (!Recharge.Instance.use(player, GetName(), 1400, true))
return;
for (int i=0 ; i<6 ; i++)
{
Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
rand.multiply(0.25);
rand.multiply(0.4);
if (team.GetColor() == ChatColor.AQUA)
{
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(1).add(rand));
_balls.add(proj);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 1f);
}
else
{
Projectile proj = player.launchProjectile(EnderPearl.class);
//Projectile proj = player.launchProjectile(EnderPearl.class);
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(1).add(rand));
_balls.add(proj);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 0.75f);
}
}
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!_balls.contains(event.GetProjectile()))
return;
//Negate
event.AddMod("Negate", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Paintball", "Shotgun", 8, true);
if (event.GetDamageePlayer() == null)
return;
double r = Math.random();
ItemStack item = null;
if (r > 0.75) item= event.GetDamageePlayer().getInventory().getHelmet();
else if (r > 0.50) item= event.GetDamageePlayer().getInventory().getChestplate();
else if (r > 0.25) item= event.GetDamageePlayer().getInventory().getLeggings();
else item= event.GetDamageePlayer().getInventory().getBoots();
LeatherArmorMeta meta = (LeatherArmorMeta)item.getItemMeta();
//Color
if (event.GetProjectile() instanceof Snowball)
meta.setColor(Color.AQUA);
else
meta.setColor(Color.FUCHSIA);
item.setItemMeta(meta);
}
}