Merge branch 'master' of ssh://dev1.mineplex.com:7999/min/master

Conflicts:
	Plugins/Libraries/craftbukkit.jar
This commit is contained in:
Jonathan Williams 2013-09-23 13:53:28 -07:00
commit 6d5acd29db
30 changed files with 1996 additions and 91 deletions

View File

@ -125,7 +125,7 @@ public class ProjectileUser
if (_hitBlock)
{
Block block = _thrown.getLocation().add(_thrown.getVelocity().normalize().multiply(0.6)).getBlock();
if (!UtilBlock.airFoliage(block))
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
{
_callback.Collide(null, block, this);
return true;

View File

@ -82,6 +82,10 @@ public class Recharge extends MiniPlugin
{
Get(cur).remove(ability);
//Event
RechargedEvent rechargedEvent = new RechargedEvent(cur, ability);
UtilServer.getServer().getPluginManager().callEvent(rechargedEvent);
if (informSet.contains(ability))
UtilPlayer.message(cur, F.main("Recharge", "You can use " + F.skill(ability) + "."));
}
@ -144,6 +148,11 @@ public class Recharge extends MiniPlugin
Get(player).put(ability, System.currentTimeMillis()+rechargeEvent.GetRecharge());
}
public void recharge(Player player, String ability)
{
Get(player).remove(ability);
}
@EventHandler
public void clearPlayer(PlayerQuitEvent event)
{

View File

@ -0,0 +1,39 @@
package mineplex.core.recharge;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class RechargedEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private String _ability;
public RechargedEvent(Player player, String ability)
{
_player = player;
_ability = ability;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Player GetPlayer()
{
return _player;
}
public String GetAbility()
{
return _ability;
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import org.bukkit.ChatColor;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl;
import nautilus.game.arcade.game.games.barbarians.Barbarians;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.castlesiege.CastleSiege;
@ -20,6 +21,7 @@ import nautilus.game.arcade.game.games.runner.Runner;
import nautilus.game.arcade.game.games.smash.SuperSmash;
import nautilus.game.arcade.game.games.snowfight.SnowFight;
import nautilus.game.arcade.game.games.spleef.Spleef;
import nautilus.game.arcade.game.games.squidshooter.SquidShooter;
import nautilus.game.arcade.game.games.turfforts.TurfForts;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival;
@ -36,6 +38,7 @@ public class GameFactory
public Game CreateGame(GameType gameType, HashMap<String, ChatColor> pastTeams)
{
if (gameType == GameType.Barbarians) return new Barbarians(_manager);
else if (gameType == GameType.BaconBrawl) return new BaconBrawl(_manager);
else if (gameType == GameType.Bridge) return new Bridge(_manager);
else if (gameType == GameType.CastleSiege) return new CastleSiege(_manager, pastTeams);
else if (gameType == GameType.DeathTag) return new DeathTag(_manager);
@ -50,6 +53,7 @@ public class GameFactory
else if (gameType == GameType.SnowFight) return new SnowFight(_manager);
else if (gameType == GameType.Smash) return new SuperSmash(_manager);
else if (gameType == GameType.Spleef) return new Spleef(_manager);
else if (gameType == GameType.SquidShooter) return new SquidShooter(_manager);
else if (gameType == GameType.TurfWars) return new TurfForts(_manager);
else if (gameType == GameType.UHC) return new UHC(_manager);
else if (gameType == GameType.ZombieSurvival) return new ZombieSurvival(_manager);

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade;
public enum GameType
{
//Mini
BaconBrawl("Bacon Brawl"),
Barbarians("A Barbarians Life"),
Bridge("The Bridges"),
CastleSiege("Castle Siege"),
@ -19,6 +20,7 @@ public enum GameType
Smash("Super Smash Mobs"),
SnowFight("Snow Fight"),
Spleef("Super Spleef"),
SquidShooter("Squid Shooter"),
TurfWars("Turf Wars"),
UHC("Ultra Hardcore"),
ZombieSurvival("Zombie Survival");

View File

@ -20,6 +20,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
@ -159,6 +160,8 @@ public abstract class Game implements Listener
public boolean AutoStart = true;
public GameState KitRegisterState = GameState.Live;
//Addons
public boolean CompassEnabled = false;
public boolean SoupEnabled = true;

View File

@ -0,0 +1,110 @@
package nautilus.game.arcade.game.games.baconbrawl;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.baconbrawl.kits.*;
import nautilus.game.arcade.kit.Kit;
public class BaconBrawl extends SoloGame
{
public BaconBrawl(ArcadeManager manager)
{
super(manager, GameType.BaconBrawl,
new Kit[]
{
new KitPig(manager),
new KitBabyPig(manager),
new KitSheepPig(manager)
},
new String[]
{
"Knock other pigs out of the arena!",
"Last pig in the arena wins!"
});
this.DamageTeamSelf = true;
this.HungerSet = 20;
this.PrepareFreeze = false;
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (GetPlayers(true).size() <= 1)
{
if (GetPlayers(true).size() == 1)
GetPlaces().add(0, GetPlayers(true).get(0));
if (GetPlaces().size() >= 1)
AddGems(GetPlaces().get(0), 15, "1st Place", false);
if (GetPlaces().size() >= 2)
AddGems(GetPlaces().get(1), 10, "2nd Place", false);
if (GetPlaces().size() >= 3)
AddGems(GetPlaces().get(2), 5, "3rd Place", false);
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
SetState(GameState.End);
AnnounceEnd(GetPlaces());
}
}
@EventHandler
public void Hunger(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
if (!IsLive())
return;
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() <= 0)
{
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.STARVATION, 4, false, true, false,
"Starvation", GetName());
}
UtilPlayer.hunger(player, -1);
}
}
@EventHandler
public void HungerRestore(CustomDamageEvent event)
{
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
UtilPlayer.hunger(damager, 2);
}
@EventHandler
public void DamageEvent(CustomDamageEvent event)
{
if (event.GetCause() == DamageCause.ENTITY_ATTACK || event.GetCause() == DamageCause.CUSTOM || event.GetCause() == DamageCause.PROJECTILE)
{
event.GetDamageeEntity().setHealth(event.GetDamageeEntity().getMaxHealth());
event.AddKnockback("Pig Wrestle", 2);
}
}
}

View File

@ -0,0 +1,83 @@
package nautilus.game.arcade.game.games.baconbrawl.kits;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBaconBlast;
import nautilus.game.arcade.kit.perks.PerkSpeed;
public class KitBabyPig extends Kit
{
public KitBabyPig(ArcadeManager manager)
{
super(manager, "Bebe Piggles", KitAvailability.Green,
new String[]
{
"Tiny pig runs so fast!"
},
new Perk[]
{
new PerkBaconBlast(),
new PerkSpeed(1),
},
EntityType.PIG,
new ItemStack(Material.PORK));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
//Disguise
DisguiseChicken disguise = new DisguiseChicken(player);
disguise.SetName(C.cYellow + player.getName());
disguise.SetCustomNameVisible(true);
disguise.setBaby();
Manager.GetDisguise().disguise(disguise);
}
@Override
public Entity SpawnEntity(Location loc)
{
EntityType type = _entityType;
if (type == EntityType.PLAYER)
type = EntityType.ZOMBIE;
LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type);
entity.setRemoveWhenFarAway(false);
entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit" + (GetAvailability() == KitAvailability.Blue ? ChatColor.GRAY + " (" + ChatColor.WHITE + "Ultra" + ChatColor.GRAY + ")" : ""));
entity.setCustomNameVisible(true);
entity.getEquipment().setItemInHand(_itemInHand);
if (type == EntityType.PIG)
{
Pig sheep = (Pig)entity;
sheep.setBaby();
}
UtilEnt.Vegetate(entity);
SpawnCustom(entity);
return entity;
}
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.baconbrawl.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBodySlam;
import nautilus.game.arcade.kit.perks.PerkJump;
public class KitPig extends Kit
{
public KitPig(ArcadeManager manager)
{
super(manager, "El Muchacho Pigo", KitAvailability.Free,
new String[]
{
"Such a fat pig. Oink."
},
new Perk[]
{
new PerkBodySlam(6, 2),
new PerkJump(1),
},
EntityType.PIG,
new ItemStack(Material.PORK));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
//Disguise
DisguisePig disguise = new DisguisePig(player);
disguise.SetName(C.cYellow + player.getName());
disguise.SetCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
}
}

View File

@ -0,0 +1,84 @@
package nautilus.game.arcade.game.games.baconbrawl.kits;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBackstabKnockback;
import nautilus.game.arcade.kit.perks.PerkPigCloak;
public class KitSheepPig extends Kit
{
public KitSheepPig(ArcadeManager manager)
{
super(manager, "'Pig'", KitAvailability.Blue,
new String[]
{
"\"...Oink?\""
},
new Perk[]
{
new PerkPigCloak(),
new PerkBackstabKnockback()
},
EntityType.SHEEP,
new ItemStack(Material.WOOL));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
//Disguise
DisguiseSheep disguise = new DisguiseSheep(player);
disguise.SetName(C.cYellow + player.getName());
disguise.SetCustomNameVisible(true);
disguise.setColor(DyeColor.PINK);
Manager.GetDisguise().disguise(disguise);
}
@Override
public Entity SpawnEntity(Location loc)
{
EntityType type = _entityType;
if (type == EntityType.PLAYER)
type = EntityType.ZOMBIE;
LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type);
entity.setRemoveWhenFarAway(false);
entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit" + (GetAvailability() == KitAvailability.Blue ? ChatColor.GRAY + " (" + ChatColor.WHITE + "Ultra" + ChatColor.GRAY + ")" : ""));
entity.setCustomNameVisible(true);
entity.getEquipment().setItemInHand(_itemInHand);
if (type == EntityType.SHEEP)
{
Sheep sheep = (Sheep)entity;
sheep.setColor(DyeColor.PINK);
}
UtilEnt.Vegetate(entity);
SpawnCustom(entity);
return entity;
}
}

View File

@ -12,7 +12,6 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.barbarians.kits.*;
import nautilus.game.arcade.kit.Kit;

View File

@ -95,6 +95,7 @@ public class DeathTag extends SoloGame
//Undead Team
_chasers = new GameTeam("Chasers", ChatColor.RED, _runners.GetSpawns());
_chasers.SetVisible(false);
GetTeamList().add(_chasers);
RestrictKits();

View File

@ -1,7 +1,10 @@
package nautilus.game.arcade.game.games.hungergames;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import org.bukkit.Chunk;
import org.bukkit.Effect;
@ -11,14 +14,20 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
@ -39,8 +48,11 @@ public class HungerGames extends SoloGame
private HashSet<Location> _openedChest = new HashSet<Location>();
private ArrayList<ItemStack> _chestLoot = new ArrayList<ItemStack>();
private ArrayList<Location> _redSpread = new ArrayList<Location>();
private HashSet<String> _redChunks = new HashSet<String>();
private ArrayList<Location> _redLocations = new ArrayList<Location>();
private int _spreadType = 0;
private boolean _ignoreLiquids = true;
private ArrayList<Entry<Integer, Integer>> _spreadTypeBlocks;
private HashMap<Player, Long> _redOutTime = new HashMap<Player, Long>();
public HungerGames(ArcadeManager manager)
{
@ -68,6 +80,7 @@ public class HungerGames extends SoloGame
this.SpawnDistanceRequirement = 48;
this.Damage = false;
this.DamageSelf = true;
this.DamageTeamSelf = true;
@ -75,7 +88,32 @@ public class HungerGames extends SoloGame
this.GemMultiplier = 2;
_spreadType = UtilMath.r(3);
System.out.println("===================");
System.out.println("SPREAD TYPE: " + _spreadType);
System.out.println("===================");
_spreadTypeBlocks = new ArrayList<Entry<Integer, Integer>>();
if (_spreadType == 0)
{
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(159, 14));
}
else if (_spreadType == 1)
{
_ignoreLiquids = false;
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(78, 0));
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(79, 0));
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(80, 0));
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(49, 0));
}
else if (_spreadType == 2)
{
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(87, 0));
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(88, 0));
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(89, 0));
_spreadTypeBlocks.add(new AbstractMap.SimpleEntry<Integer, Integer>(153, 0));
}
}
@Override
@ -266,54 +304,37 @@ public class HungerGames extends SoloGame
Manager.GetCondition().EndCondition(damager, null, "Start Speed");
}
//If an item spawns and no one is there to see it, does it really spawn? No.
@EventHandler
public void ItemSpawn(ItemSpawnEvent event)
{
for (Player player : GetPlayers(true))
if (UtilMath.offset(player, event.getEntity()) < 6)
return;
event.setCancelled(true);
}
@EventHandler
public void RedBorderStart(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
return;
long time = System.currentTimeMillis();
/*
//X Borders
for (int x=WorldData.MinX/16 ; x<=WorldData.MaxX/16 ; x++)
{
_redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(x, WorldData.MinZ/16)));
_redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(x, WorldData.MaxZ/16)));
}
//Z Borders
for (int z=WorldData.MinZ/16 ; z<=WorldData.MaxZ/16 ; z++)
{
_redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(WorldData.MinX/16, z)));
_redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(WorldData.MaxX/16, z)));
}
*/
//Start Red
Block block;
if (true)
{
block = WorldData.World.getHighestBlockAt(0, 0);
while (!UtilBlock.solid(block))
block = block.getRelative(BlockFace.DOWN);
_redSpread.add(block.getLocation());
return;
}
for (int x=WorldData.MinX ; x<=WorldData.MaxX ; x++)
{
block = WorldData.World.getHighestBlockAt(x, WorldData.MinZ);
while (!UtilBlock.solid(block))
block = block.getRelative(BlockFace.DOWN);
_redSpread.add(block.getLocation());
_redLocations.add(block.getLocation());
block = WorldData.World.getHighestBlockAt(x, WorldData.MaxZ);
while (!UtilBlock.solid(block))
block = block.getRelative(BlockFace.DOWN);
_redSpread.add(block.getLocation());
_redLocations.add(block.getLocation());
}
for (int z=WorldData.MinZ ; z<=WorldData.MaxZ ; z++)
@ -321,12 +342,12 @@ public class HungerGames extends SoloGame
block = WorldData.World.getHighestBlockAt(WorldData.MinX, z);
while (!UtilBlock.solid(block))
block = block.getRelative(BlockFace.DOWN);
_redSpread.add(block.getLocation());
_redLocations.add(block.getLocation());
block = WorldData.World.getHighestBlockAt(WorldData.MaxX, z);
while (!UtilBlock.solid(block))
block = block.getRelative(BlockFace.DOWN);
_redSpread.add(block.getLocation());
_redLocations.add(block.getLocation());
}
}
@ -339,21 +360,27 @@ public class HungerGames extends SoloGame
if (!IsLive())
return;
if (_redSpread.isEmpty())
if (_redLocations.isEmpty())
return;
System.out.println(_redSpread.size());
int max = Math.max(5, Math.min(400, _redSpread.size()/10));
int max = Math.max(5, Math.min(400, _redLocations.size()/10));
for (int i=0 ; i<max ; i++)
{
if (_redSpread.isEmpty())
return;
if (_redLocations.isEmpty())
break;
Location loc = _redSpread.get(UtilMath.r(_redSpread.size()));
Location loc = _redLocations.remove(UtilMath.r(_redLocations.size()));
RedChangeBlock(loc, 159, (byte)14);
//Already Red
if (IsRed(loc.getBlock()))
{
i = Math.max(0, i-1);
continue;
}
//Set to Red
SetRed(loc);
//Spread to Neighbours
Block block = loc.getBlock();
@ -389,43 +416,207 @@ public class HungerGames extends SoloGame
public boolean RedSpread(Block block)
{
if (block.isLiquid())
return false;
if (block.getTypeId() == 159 && block.getData() == 14)
return false;
//Boundaries
if (block.getX() < WorldData.MinX) return false;
if (block.getX() > WorldData.MaxX) return false;
if (block.getZ() < WorldData.MinZ) return false;
if (block.getZ() > WorldData.MaxZ) return false;
if (!UtilBlock.isVisible(block))
return false;
if (!UtilBlock.solid(block) || UtilBlock.airFoliage(block))
//Liquid
if (_ignoreLiquids && block.isLiquid())
{
return false;
}
//Pre-Red
if (IsRed(block))
{
return false;
}
if (!UtilBlock.solid(block) || UtilBlock.airFoliage(block) || block.getType() == Material.CHEST)
{
if (!block.isLiquid())
{
while (block.getType() == Material.VINE)
{
RedChangeBlock(block.getLocation(), 0, (byte)0);
block = block.getRelative(BlockFace.DOWN);
}
//Remove Foliage
if (block.getType() != Material.AIR)
RedChangeBlock(block.getLocation(), 0, (byte)0);
return false;
}
}
//if (_redChunks.contains(UtilWorld.chunkToStr(block.getChunk())))
if (!_redSpread.contains(block.getLocation()))
//Outside Boundaries
if (block.getX() < WorldData.MinX || block.getX() > WorldData.MaxX || block.getZ() < WorldData.MinZ || block.getZ() > WorldData.MaxZ)
{
_redSpread.add(block.getLocation());
return false;
}
//Inside Boundary
if (block.getChunk().getX() == 0 && block.getChunk().getZ() == 0)
{
return false;
}
//Not Visible
if (!UtilBlock.isVisible(block))
{
return false;
}
//Apply
_redLocations.add(block.getLocation());
return true;
}
public void RedChangeBlock(Location loc, int id, byte data)
{
MapUtil.ChunkBlockChange(loc, id, data);
for (Player player : UtilServer.getPlayers())
{
if (player.getLocation().getChunk().getX() - loc.getChunk().getX() > 6)
continue;
if (player.getLocation().getChunk().getZ() - loc.getChunk().getZ() > 6)
continue;
player.sendBlockChange(loc, id, data);
}
}
public boolean IsRed(Block block)
{
for (Entry<Integer,Integer> entry : _spreadTypeBlocks)
{
if (block.getTypeId() == entry.getKey() && block.getData() == entry.getValue())
return true;
}
return false;
}
public void RedChangeBlock(Location loc, int id, byte data)
public void SetRed(Location loc)
{
MapUtil.ChunkBlockChange(loc, id, data);
for (Player player : UtilServer.getPlayers())
player.sendBlockChange(loc, id, data);
//Red
if (_spreadType == 0)
{
RedChangeBlock(loc, 159, (byte)14);
}
//Snow
else if (_spreadType == 1)
{
if (loc.getBlock().getType() == Material.LEAVES) RedChangeBlock(loc, 79, (byte)0);
else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0);
else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0);
else RedChangeBlock(loc, 80, (byte)0);
}
//Nether
else
{
if (loc.getBlock().getType() == Material.LEAVES) RedChangeBlock(loc, 88, (byte)0);
else
{
double r = Math.random();
if (r > 0.1) RedChangeBlock(loc, 87, (byte)0);
else RedChangeBlock(loc, 153, (byte)0);
}
}
}
@EventHandler
public void RedAttack(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Player player : GetPlayers(true))
{
boolean near = false;
for (Block block : UtilBlock.getInRadius(player.getLocation(), 5d).keySet())
{
if (!IsRed(block))
continue;
near = true;
//Red
if (_spreadType == 0)
{
if (block.getRelative(BlockFace.UP).getType() == Material.AIR)
{
block.getRelative(BlockFace.UP).setType(Material.FIRE);
break;
}
}
//Snow
else if (_spreadType == 1)
{
if (Math.random() > 0.8)
{
Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation());
Snowball ball = player.getWorld().spawn(block.getLocation().add(0.5, 1.5, 0.5).subtract(traj.clone().multiply(8 + UtilMath.r(8))), Snowball.class);
ball.setVelocity(UtilAlg.getTrajectory(ball.getLocation(), player.getEyeLocation().add(0, 3, 0)).add(new Vector(Math.random()-0.5, Math.random()-0.5, Math.random()-0.5).multiply(0.1)));
}
}
//Nether
if (_spreadType == 2)
{
if (block.getRelative(BlockFace.UP).getType() == Material.AIR)
{
block.getRelative(BlockFace.UP).setType(Material.FIRE);
break;
}
}
}
if (!near)
{
if (!UtilEnt.isGrounded(player))
{
Block block = player.getLocation().getBlock();
while (!UtilBlock.solid(block) && block.getY() > 0)
block = block.getRelative(BlockFace.DOWN);
if (IsRed(block) || block.getY() == 0)
near = true;
}
}
if (near)
{
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.VOID, 1, false, true, false,
"Hunger Games", "Border");
player.sendMessage("INFECTION!");
}
}
}
@EventHandler
public void SnowballDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!(event.GetProjectile() instanceof Snowball))
return;
event.AddMod("Snowball", "Snowball", 1, false);
event.AddKnockback("Snowball", 4);
}
@EventHandler
public void DebugCmd(PlayerCommandPreprocessEvent event)
{
}
}

View File

@ -35,7 +35,7 @@ public class KitBlaze extends SmashKit
new Perk[]
{
new PerkSmashStats(6, 1.5, 0.25, 5),
new PerkSmashStats(6, 1.5, 0.15, 5),
new PerkDoubleJump("Double Jump", 1, 1, false),
new PerkKnockbackFire(1.50),
new PerkSpeed(0),

View File

@ -0,0 +1,208 @@
package nautilus.game.arcade.game.games.squidshooter;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.quiver.QuiverScore;
import nautilus.game.arcade.game.games.squidshooter.kits.*;
import nautilus.game.arcade.kit.Kit;
public class SquidShooter extends SoloGame
{
private ArrayList<QuiverScore> _ranks = new ArrayList<QuiverScore>();
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
public SquidShooter(ArcadeManager manager)
{
super(manager, GameType.SquidShooter,
new Kit[]
{
new KitRifle(manager),
new KitShotgun(manager),
new KitSniper(manager),
},
new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Attack",
C.cYellow + "Tap Crouch" + C.cGray + " to use " + C.cGreen + "Squid Thrust",
"First player to 20 kills wins."
});
this.DeathOut = false;
this.DamageSelf = false;
this.DamageTeamSelf = true;
this.PrepareFreeze = false;
this.SpawnDistanceRequirement = 16;
this.CompassEnabled = true;
this.KitRegisterState = GameState.Prepare;
}
@EventHandler(priority = EventPriority.HIGH)
public void GameStateChange(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
GetObjectiveSide().setDisplayName(C.cWhite + C.Bold + "First to " + C.cGold + C.Bold + "20 Kills");
}
@EventHandler
public void Death(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
return;
//Score
AddKill(player);
}
public void AddKill(Player player)
{
//Rank
for (QuiverScore score : _ranks)
{
if (score.Player.equals(player))
{
score.Kills += 1;
EndCheck();
return;
}
}
_ranks.add(new QuiverScore(player, 1));
}
private void SortScores()
{
for (int i=0 ; i<_ranks.size() ; i++)
{
for (int j=_ranks.size()-1 ; j>0 ; j--)
{
if (_ranks.get(j).Kills > _ranks.get(j-1).Kills)
{
QuiverScore temp = _ranks.get(j);
_ranks.set(j, _ranks.get(j-1));
_ranks.set(j-1, temp);
}
}
}
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
//Wipe Last
for (String string : _lastScoreboard)
{
GetScoreboard().resetScores(Bukkit.getOfflinePlayer(string));
}
_lastScoreboard.clear();
SortScores();
//Write New
for (QuiverScore score : _ranks)
{
String out = score.Kills + " " + C.cGreen + score.Player.getName();
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(score.Kills);
}
}
@EventHandler
public void AirDamage(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
if (!IsLive())
return;
for (Player player : GetPlayers(true))
{
if (player.getLocation().getBlock().isLiquid())
{
player.setFoodLevel(20);
continue;
}
//Damage
if (player.getFoodLevel() == 0)
player.damage(1);
//Hunger Lower
UtilPlayer.hunger(player, -1);
//Slow
if (UtilEnt.isGrounded(player))
Manager.GetCondition().Factory().Slow("On Land", player, player, 0.9, 2, false, false, false, false);
}
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
SortScores();
if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1)
{
//Set Places
_places.clear();
for (int i=0 ; i<_ranks.size() ; i++)
_places.add(i, _ranks.get(i).Player);
//Award Gems
if (_ranks.size() >= 1)
AddGems(_ranks.get(0).Player, 20, "1st Place", false);
if (_ranks.size() >= 2)
AddGems(_ranks.get(1).Player, 15, "2nd Place", false);
if (_ranks.size() >= 3)
AddGems(_ranks.get(2).Player, 10, "3rd Place", false);
//Participation
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
SetState(GameState.End);
AnnounceEnd(_places);
}
}
}

View File

@ -0,0 +1,54 @@
package nautilus.game.arcade.game.games.squidshooter.kits;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkSquidRifle;
import nautilus.game.arcade.kit.perks.PerkSquidSwim;
public class KitRifle extends Kit
{
public KitRifle(ArcadeManager manager)
{
super(manager, "Squid Gunner", KitAvailability.Free,
new String[]
{
"All rounder squid! Fast projectile and reload!"
},
new Perk[]
{
new PerkSquidSwim(),
new PerkSquidRifle()
},
EntityType.SQUID,
new ItemStack(Material.INK_SACK));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
ItemStack helm = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET);
helm.addEnchantment(Enchantment.OXYGEN, 3);
player.getInventory().setHelmet(helm);
//Disguise
DisguiseSquid disguise = new DisguiseSquid(player);
disguise.SetName(C.cWhite + player.getName());
disguise.SetCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
}
}

View File

@ -0,0 +1,54 @@
package nautilus.game.arcade.game.games.squidshooter.kits;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkSquidShotgun;
import nautilus.game.arcade.kit.perks.PerkSquidSwim;
public class KitShotgun extends Kit
{
public KitShotgun(ArcadeManager manager)
{
super(manager, "Squid Blaster", KitAvailability.Green,
new String[]
{
"Fires many slow projectiles."
},
new Perk[]
{
new PerkSquidSwim(),
new PerkSquidShotgun()
},
EntityType.SQUID,
new ItemStack(Material.INK_SACK));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
ItemStack helm = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET);
helm.addEnchantment(Enchantment.OXYGEN, 3);
player.getInventory().setHelmet(helm);
//Disguise
DisguiseSquid disguise = new DisguiseSquid(player);
disguise.SetName(C.cWhite + player.getName());
disguise.SetCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
}
}

View File

@ -0,0 +1,54 @@
package nautilus.game.arcade.game.games.squidshooter.kits;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkSquidSniper;
import nautilus.game.arcade.kit.perks.PerkSquidSwim;
public class KitSniper extends Kit
{
public KitSniper(ArcadeManager manager)
{
super(manager, "Squid Sniper", KitAvailability.Blue,
new String[]
{
"Hitting someone with Ink Sniper recharges it!"
},
new Perk[]
{
new PerkSquidSwim(),
new PerkSquidSniper()
},
EntityType.SQUID,
new ItemStack(Material.INK_SACK));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
ItemStack helm = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET);
helm.addEnchantment(Enchantment.OXYGEN, 3);
player.getInventory().setHelmet(helm);
//Disguise
DisguiseSquid disguise = new DisguiseSquid(player);
disguise.SetName(C.cWhite + player.getName());
disguise.SetCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
}
}

View File

@ -0,0 +1,62 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkBackstabKnockback extends Perk
{
public PerkBackstabKnockback()
{
super("Backstab", new String[]
{
C.cGray + "+250% Knockback from behind opponents.",
});
}
@EventHandler(priority = EventPriority.HIGH)
public void Damage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
return;
Player damager = event.GetDamagerPlayer(false);
if (damager == null) return;
if (!Kit.HasKit(damager))
return;
LivingEntity damagee = event.GetDamageeEntity();
if (damagee == null) return;
Vector look = damagee.getLocation().getDirection();
look.setY(0);
look.normalize();
Vector from = damager.getLocation().toVector().subtract(damagee.getLocation().toVector());
from.setY(0);
from.normalize();
Vector check = new Vector(look.getX() * -1, 0, look.getZ() * -1);
if (check.subtract(from).length() < 0.8)
{
//Damage
event.AddKnockback("Backstab Knockback", 2.5);
//Effect
damagee.getWorld().playSound(damagee.getLocation(), Sound.PIG_DEATH, 1f, 2f);
return;
}
}
}

View File

@ -0,0 +1,115 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.kit.Perk;
public class PerkBaconBlast extends Perk implements IThrown
{
public PerkBaconBlast()
{
super("Bacon Blast", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Bacon Blast"
});
}
@EventHandler
public void Shoot(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 3000, true))
return;
event.setCancelled(true);
UtilInv.Update(player);
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.PORK, (byte)0, 16));
UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false);
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true,
null, 1f, 1f,
null, 1, UpdateType.SLOW,
2d);
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 2f);
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Explode(data);
if (target == null)
return;
//Damage Event
Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null,
DamageCause.PROJECTILE, 6, true, true, false,
UtilEnt.getName(data.GetThrower()), GetName());
}
@Override
public void Idle(ProjectileUser data)
{
Explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
Explode(data);
}
public void Explode(ProjectileUser data)
{
data.GetThrown().getWorld().createExplosion(data.GetThrown().getLocation(), 0.5f);
data.GetThrown().remove();
}
}

View File

@ -86,7 +86,7 @@ public class PerkFirefly extends Perk
FireflyData data = dataIterator.next();
//Teleport
if (!UtilTime.elapsed(data.Time, 1000))
if (!UtilTime.elapsed(data.Time, 1250))
{
data.Player.setVelocity(new Vector(0,0,0));//.teleport(data.Location);
data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.2f, 0.6f);
@ -148,7 +148,7 @@ public class PerkFirefly extends Perk
//Damage Event
Manager.GetDamage().NewDamageEvent(other, data.Player, null,
DamageCause.CUSTOM, 12, true, true, false,
DamageCause.CUSTOM, 10, true, true, false,
data.Player.getName(), GetName());
UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(data.Player) + data.Player.getName()) + " hit you with " + F.elem(GetName()) + "."));
@ -174,7 +174,7 @@ public class PerkFirefly extends Perk
if (!data.Player.equals(event.GetDamageeEntity()))
continue;
if (!UtilTime.elapsed(data.Time, 1000))// && event.GetCause() == DamageCause.PROJECTILE)
if (!UtilTime.elapsed(data.Time, 1250))// && event.GetCause() == DamageCause.PROJECTILE)
{
dataIterator.remove();
}
@ -191,6 +191,6 @@ public class PerkFirefly extends Perk
if (event.GetReason() == null || !event.GetReason().contains(GetName()))
return;
event.AddKnockback(GetName(), 2.5);
event.AddKnockback(GetName(), 2);
}
}

View File

@ -0,0 +1,104 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkPigCloak extends Perk
{
public PerkPigCloak()
{
super("Cloak", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Cloak"
});
}
@EventHandler
public void Use(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
event.setCancelled(true);
if (!Recharge.Instance.use(player, GetName(), GetName(), 10000, true))
return;
//Action
Manager.GetCondition().Factory().Cloak(GetName(), player, player, 5, false, false);
for (int i=0 ; i<3 ; i++)
{
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 2f, 0.5f);
player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80);
}
//Inform
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
}
@EventHandler(priority = EventPriority.HIGH)
public void EndDamagee(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
if (!Kit.HasKit(damagee))
return;
//End
Manager.GetCondition().EndCondition(damagee, null, GetName());
}
@EventHandler(priority = EventPriority.HIGH)
public void EndDamager(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player damager = event.GetDamagerPlayer(true);
if (damager == null) return;
if (!Kit.HasKit(damager))
return;
//End
Manager.GetCondition().EndCondition(damager, null, GetName());
}
@EventHandler
public void EndInteract(PlayerInteractEvent event)
{
if (!Kit.HasKit(event.getPlayer()))
return;
Manager.GetCondition().EndCondition(event.getPlayer(), null, GetName());
}
@EventHandler
public void Reset(PlayerDeathEvent event)
{
//Remove Condition
Manager.GetCondition().EndCondition(event.getEntity(), null, GetName());
}
}

View File

@ -0,0 +1,177 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkSquidRifle extends Perk implements IThrown
{
private HashMap<Firework, Vector> _fireworks = new HashMap<Firework, Vector>();
public PerkSquidRifle()
{
super("Ink Blaster", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Blaster"
});
}
@EventHandler
public void Recharge(RechargedEvent event)
{
if (!event.GetAbility().equals(GetName()))
return;
event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 3f, 1f);
}
@EventHandler
public void Shoot(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 1500, true))
return;
event.setCancelled(true);
UtilInv.Update(player);
//Firework
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(false).build();
try
{
Vector vel = player.getLocation().getDirection().multiply(1.8);
Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel);
_fireworks.put(fw, vel);
Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true,
null, 1f, 1f,
null, 1, UpdateType.SLOW,
2.5d);
}
catch (Exception e)
{
e.printStackTrace();
}
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.75f);
}
@EventHandler
public void FireworkUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Firework> fwIterator = _fireworks.keySet().iterator();
while (fwIterator.hasNext())
{
Firework fw = fwIterator.next();
if (!fw.isValid())
{
fwIterator.remove();
continue;
}
fw.setVelocity(_fireworks.get(fw));
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Explode(data);
if (target == null)
return;
//Damage Event
Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null,
DamageCause.PROJECTILE, 50, false, true, false,
UtilEnt.getName(data.GetThrower()), GetName());
}
@Override
public void Idle(ProjectileUser data)
{
Explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
Explode(data);
}
public void Explode(ProjectileUser data)
{
if (!(data.GetThrown() instanceof Firework))
{
data.GetThrown().remove();
return;
}
Firework fw = (Firework)data.GetThrown();
try
{
Manager.GetFirework().detonateFirework(fw);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,194 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkSquidShotgun extends Perk implements IThrown
{
private HashMap<Firework, Vector> _fireworks = new HashMap<Firework, Vector>();
public PerkSquidShotgun()
{
super("Ink Shotgun", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun"
});
}
@EventHandler
public void Recharge(RechargedEvent event)
{
if (!event.GetAbility().equals(GetName()))
return;
event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 3f, 1f);
}
@EventHandler
public void Shoot(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 2500, true))
return;
event.setCancelled(true);
UtilInv.Update(player);
//Firework
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.BURST).trail(false).build();
for (int i=0 ; i<6 ; i++)
{
Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
random.normalize();
random.multiply(0.3);
try
{
Vector vel = player.getLocation().getDirection().multiply(1.4).add(random);
Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel);
_fireworks.put(fw, vel);
Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true,
null, 1f, 1f,
null, 1, UpdateType.SLOW,
2.5d);
}
catch (Exception e)
{
e.printStackTrace();
}
}
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.75f);
}
@EventHandler
public void FireworkUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Firework> fwIterator = _fireworks.keySet().iterator();
while (fwIterator.hasNext())
{
Firework fw = fwIterator.next();
if (!fw.isValid())
{
fwIterator.remove();
continue;
}
fw.setVelocity(_fireworks.get(fw));
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Explode(data);
if (target == null)
return;
//Damage Event
Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null,
DamageCause.PROJECTILE, 12, false, true, false,
UtilEnt.getName(data.GetThrower()), GetName());
//Recharge
if (data.GetThrower() instanceof Player)
{
Player player = (Player)data.GetThrower();
Recharge.Instance.recharge(player, GetName());
player.playSound(player.getLocation(), Sound.NOTE_STICKS, 3f, 1f);
}
}
@Override
public void Idle(ProjectileUser data)
{
Explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
Explode(data);
}
public void Explode(ProjectileUser data)
{
if (!(data.GetThrown() instanceof Firework))
{
data.GetThrown().remove();
return;
}
Firework fw = (Firework)data.GetThrown();
try
{
Manager.GetFirework().detonateFirework(fw);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,185 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkSquidSniper extends Perk implements IThrown
{
private HashMap<Firework, Vector> _fireworks = new HashMap<Firework, Vector>();
public PerkSquidSniper()
{
super("Ink Sniper", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Sniper"
});
}
@EventHandler
public void Recharge(RechargedEvent event)
{
if (!event.GetAbility().equals(GetName()))
return;
event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 3f, 1f);
}
@EventHandler
public void Shoot(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 4500, true))
return;
event.setCancelled(true);
UtilInv.Update(player);
//Firework
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false).build();
try
{
Vector vel = player.getLocation().getDirection().multiply(3);
Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel);
_fireworks.put(fw, vel);
Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true,
null, 1f, 1f,
null, 1, UpdateType.SLOW,
3d);
}
catch (Exception e)
{
e.printStackTrace();
}
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.75f);
}
@EventHandler
public void FireworkUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Firework> fwIterator = _fireworks.keySet().iterator();
while (fwIterator.hasNext())
{
Firework fw = fwIterator.next();
if (!fw.isValid())
{
fwIterator.remove();
continue;
}
fw.setVelocity(_fireworks.get(fw));
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Explode(data);
if (target == null)
return;
//Damage Event
Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null,
DamageCause.PROJECTILE, 50, false, true, false,
UtilEnt.getName(data.GetThrower()), GetName());
//Recharge
if (data.GetThrower() instanceof Player)
{
Player player = (Player)data.GetThrower();
Recharge.Instance.recharge(player, GetName());
player.playSound(player.getLocation(), Sound.NOTE_STICKS, 3f, 1f);
}
}
@Override
public void Idle(ProjectileUser data)
{
Explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
Explode(data);
}
public void Explode(ProjectileUser data)
{
if (!(data.GetThrown() instanceof Firework))
{
data.GetThrown().remove();
return;
}
Firework fw = (Firework)data.GetThrown();
try
{
Manager.GetFirework().detonateFirework(fw);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,83 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkSquidSwim extends Perk
{
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
public PerkSquidSwim()
{
super("Swimming", new String[]
{
C.cYellow + "Tap Crouch" + C.cGray + " to use " + C.cGreen + "Squid Thrust"
});
}
@EventHandler
public void Use(PlayerToggleSneakEvent event)
{
if (event.isCancelled())
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
event.setCancelled(true);
if (!player.getLocation().getBlock().isLiquid())
return;
if (!Recharge.Instance.use(player, GetName(), 500, false))
return;
//Velocity
UtilAction.velocity(player, 0.9, 0.2, 2, false);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.5f, 0.75f);
_active.put(player, System.currentTimeMillis());
}
@EventHandler
public void Reuse(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Player> swimIterator = _active.keySet().iterator();
while (swimIterator.hasNext())
{
Player player = swimIterator.next();
if (UtilTime.elapsed(_active.get(player), 200))
{
swimIterator.remove();
continue;
}
if (!player.getLocation().getBlock().isLiquid())
continue;
UtilAction.velocity(player, 0.9, 0.2, 2, false);
}
}
}

View File

@ -598,7 +598,7 @@ public class GameFlagManager implements Listener
if (!game.PrepareFreeze)
return;
if (UtilMath.offset(event.getFrom(), event.getTo()) <= 0)
if (UtilMath.offset2d(event.getFrom(), event.getTo()) <= 0)
return;
event.getFrom().setPitch(event.getTo().getPitch());

View File

@ -210,7 +210,7 @@ public class GameManager implements Listener
@EventHandler
public void KitRegister(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
if (event.GetState() != event.GetGame().KitRegisterState)
return;
event.GetGame().RegisterKits();

View File

@ -6,6 +6,7 @@ import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector;
public class FireworkHandler
{
@ -57,4 +58,44 @@ public class FireworkHandler
}
return null;
}
public Firework launchFirework(Location loc, FireworkEffect fe, Vector dir) throws Exception
{
Firework fw = (Firework) loc.getWorld().spawn(loc, Firework.class);
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fe);
fw.setFireworkMeta(data);
fw.setVelocity(dir);
return fw;
}
public void detonateFirework(Firework fw) throws Exception
{
Object nms_world = null;
Object nms_firework = null;
if(world_getHandle == null)
{
world_getHandle = getMethod(fw.getWorld().getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
nms_world = world_getHandle.invoke(fw.getWorld(), (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
if(nms_world_broadcastEntityEffect == null)
{
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
fw.remove();
}
}

Binary file not shown.