Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-11-13 19:15:05 -08:00
commit 2cf76ae5b4
27 changed files with 1721 additions and 32 deletions

View File

@ -139,14 +139,17 @@ public class UtilAlg
public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB)
{
if (loc.getX() < Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() > Math.max(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (loc.getY() < Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() > Math.max(cornerA.getY(), cornerB.getY())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() < Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() > Math.max(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}

View File

@ -109,6 +109,19 @@ public class UtilParticle
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count)
{
for (Player player : UtilServer.getPlayers())
{
//Dont send to players who cannot see it!
if (type != ParticleType.FIREWORKS_SPARK &&
type != ParticleType.LARGE_EXPLODE &&
type != ParticleType.HUGE_EXPLOSION)
{
if (UtilMath.offset(player.getLocation(), location) > 24)
{
continue;
}
}
PlayParticle(player, type, location, offsetX, offsetY, offsetZ, speed, count);
}
}
}

View File

@ -233,10 +233,16 @@ public class PunishPage extends CraftInventoryCustom implements Listener
examplePrefixEx + " Forcefield",
examplePrefixEx + " Speed Hack",
examplePrefixEx + " Reach Hack",
examplePrefixEx + " Speed Hack",
examplePrefixEx + " Other Hack",
" ",
examplePrefix + "Hack Reports;",
examplePrefixEx + " Forum Report",
examplePrefixEx + " Staff Report",
examplePrefix + "Hack Reports (SR & FR);",
examplePrefixEx + " Forcefield",
examplePrefixEx + " Speed Hack",
examplePrefixEx + " Reach Hack",
examplePrefixEx + " Speed Hack",
examplePrefixEx + " Other Hack",
examplePrefixEx + " Fly Hack",
}
, 1, false, true), new PunishButton(this, Category.Hacking, 2, true, getDuration(Category.Hacking, 2, offenseMap)));

View File

@ -0,0 +1,25 @@
package mineplex.mapparser;
import org.bukkit.block.Block;
import org.bukkit.Material;
public class BlockData
{
public Block Block;
public Material Material;
public byte Data;
public long Time;
public BlockData(Block block)
{
Block = block;
Material = block.getType();
Data = block.getData();
Time = System.currentTimeMillis();
}
public void restore()
{
Block.setTypeIdAndData(Material.getId(), Data, true);
}
}

View File

@ -14,6 +14,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -22,6 +23,7 @@ import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockSpreadEvent;
@ -45,7 +47,10 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -533,18 +538,17 @@ public class MapParser extends JavaPlugin implements Listener
if (!event.getMessage().toLowerCase().startsWith("/tp"))
return;
event.setCancelled(true);
Player player = event.getPlayer();
String[] tokens = event.getMessage().split(" ");
if (tokens.length != 2)
{
UtilPlayer.message(player, F.main("Game", "Invalid Input. " + F.elem("/tp <Name>") + "."));
return;
}
event.setCancelled(true);
Player target = UtilPlayer.searchOnline(player, tokens[1], true);
if (target != null)
{
@ -552,4 +556,136 @@ public class MapParser extends JavaPlugin implements Listener
player.teleport(target);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void FlySpeed(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().toLowerCase().startsWith("/speed"))
return;
Player player = event.getPlayer();
String[] tokens = event.getMessage().split(" ");
if (tokens.length != 2)
{
return;
}
event.setCancelled(true);
try
{
float speed = Float.parseFloat(tokens[1]);
player.setFlySpeed(speed);
UtilPlayer.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + "."));
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Game", "Invalid Speed Input."));
}
}
private HashMap<Player, ArrayList<HashSet<BlockData>>> treeHistory = new HashMap<Player, ArrayList<HashSet<BlockData>>>();
@EventHandler(priority = EventPriority.HIGHEST)
public void treeRemover(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{
return;
}
Player player = event.getPlayer();
if (!UtilGear.isMat(player.getItemInHand(), Material.NETHER_STAR))
return;
event.setCancelled(true);
//Remove
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (event.getClickedBlock().getType() != Material.LOG)
{
player.sendMessage(C.cRed + C.Bold + "TreeTool: " + ChatColor.RESET + "Left-Click on Log");
return;
}
HashSet<Block> toRemove = searchLog(new HashSet<Block>(), event.getClickedBlock());
if (toRemove.isEmpty())
{
player.sendMessage(C.cRed + C.Bold + "TreeTool: " + ChatColor.RESET + "Left-Click on Log");
return;
}
HashSet<BlockData> history = new HashSet<BlockData>();
for (Block block : toRemove)
{
history.add(new BlockData(block));
block.setType(Material.AIR);
}
if (!treeHistory.containsKey(player))
treeHistory.put(player, new ArrayList<HashSet<BlockData>>());
treeHistory.get(player).add(0, history);
player.sendMessage(C.cRed + C.Bold + "TreeTool: " + ChatColor.RESET + "Tree Removed");
while (treeHistory.get(player).size() > 10)
treeHistory.get(player).remove(10);
}
else if (UtilEvent.isAction(event, ActionType.R))
{
if (!treeHistory.containsKey(player) || treeHistory.get(player).isEmpty())
{
player.sendMessage(C.cGreen + C.Bold + "TreeTool: " + ChatColor.RESET + "No Tree History");
return;
}
HashSet<BlockData> datas = treeHistory.get(player).remove(0);
for (BlockData data : datas)
data.restore();
player.sendMessage(C.cGreen + C.Bold + "TreeTool: " + ChatColor.RESET + "Tree Restored");
}
}
private HashSet<Block> searchLog(HashSet<Block> blocks, Block current)
{
//Not Tree
if (current.getType() != Material.LOG && current.getType() != Material.LEAVES)
return blocks;
if (!blocks.add(current))
return blocks;
for (Block other : UtilBlock.getSurrounding(current, true))
{
if (current.getType() != Material.LOG && current.getType() != Material.LEAVES)
continue;
if (blocks.contains(other))
continue;
//Dont spread from leaves to log
if (current.getType() == Material.LEAVES && other.getType() == Material.LOG)
continue;
searchLog(blocks, other);
}
return blocks;
}
}

View File

@ -47,6 +47,7 @@ import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.tug.Tug;
import nautilus.game.arcade.game.games.turfforts.TurfForts;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.game.games.wither.WitherGame;
import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival;
public class GameFactory
@ -102,6 +103,7 @@ public class GameFactory
else if (gameType == GameType.Tug) return new Tug(_manager);
else if (gameType == GameType.TurfWars) return new TurfForts(_manager);
else if (gameType == GameType.UHC) return new UHC(_manager);
else if (gameType == GameType.WitherAssault) return new WitherGame(_manager);
else if (gameType == GameType.ZombieSurvival) return new ZombieSurvival(_manager);
else return null;
}

View File

@ -48,6 +48,7 @@ public enum GameType
Tug("Tug of Wool"),
TurfWars("Turf Wars"),
UHC("Ultra Hardcore"),
WitherAssault("Wither Assault"),
ZombieSurvival("Zombie Survival");
String _name;

View File

@ -67,7 +67,7 @@ public class ChampionsDominate extends Domination
this.DisableKillCommand = false;
registerStatTrackers(
new KillReasonStatTracker(this, "Backstab", "Assassination"),
new KillReasonStatTracker(this, "Backstab", "Assassination", false),
new ElectrocutionStatTracker(this),
new TheLongestShotStatTracker(this),
new SeismicSlamStatTracker(this)

View File

@ -67,7 +67,7 @@ public class ChampionsTDM extends TeamDeathmatch
registerStatTrackers(
new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"),
new KillAllOpposingStatTracker(this),
new KillReasonStatTracker(this, "Backstab", "Assassination"),
new KillReasonStatTracker(this, "Backstab", "Assassination", false),
new ElectrocutionStatTracker(this),
new TheLongestShotStatTracker(this),
new SeismicSlamStatTracker(this)

View File

@ -62,7 +62,7 @@ public class Domination extends TeamGame
new String[]
{
"Capture Beacons for Points",
"+500 Points for Emerald Powerups",
"+300 Points for Emerald Powerups",
"+50 Points for Kills",
"First team to 15000 Points wins"

View File

@ -284,10 +284,10 @@ public class MineStrike extends TeamGame
};
registerStatTrackers(
new KillReasonStatTracker(this, "Headshot", "BoomHeadshot"),
new KillReasonStatTracker(this, "Headshot", "BoomHeadshot", true),
new KillAllOpposingMineStrikeRoundStatTracker(this),
new KaboomStatTracker(this),
new KillReasonStatTracker(this, "Backstab", "Assassination"),
new KillReasonStatTracker(this, "Backstab", "Assassination", false),
new MineStrikeLastAliveKillStatTracker(this),
new KillFastStatTracker(this, 4, 5, "KillingSpree"),
new KillsWithConditionStatTracker(this, "Blindfolded", ConditionType.BLINDNESS, "Flash Bang", 2)

View File

@ -292,7 +292,7 @@ public class SheepGame extends TeamGame
if (player.getPassenger() != null && player.getPassenger() instanceof Player)
{
DropSheep(player, 500);
DropSheep(player, 500, false);
}
//Holding too many
@ -365,7 +365,7 @@ public class SheepGame extends TeamGame
return;
if (player.getPassenger() != null)
DropSheep(player, 500);
DropSheep(player, 500, false);
if (!Recharge.Instance.usable(player, "Sheep Stack"))
return;
@ -396,7 +396,7 @@ public class SheepGame extends TeamGame
@EventHandler
public void DeathDrop(PlayerDeathEvent event)
{
DropSheep(event.getEntity(), 0);
DropSheep(event.getEntity(), 0, false);
event.getEntity().eject();
}
@ -404,13 +404,13 @@ public class SheepGame extends TeamGame
@EventHandler
public void DeathDrop(PlayerItemHeldEvent event)
{
DropSheep(event.getPlayer(), 0);
DropSheep(event.getPlayer(), 0, false);
}
public void DropSheep(Player player, long cooldown)
public void DropSheep(Player player, long cooldown, boolean calledByCarrier)
{
//Brute can only throw
if (GetKit(player) instanceof KitBrute)
if (calledByCarrier && GetKit(player) instanceof KitBrute)
return;
boolean hadSheep = false;
@ -443,7 +443,7 @@ public class SheepGame extends TeamGame
@EventHandler
public void Drop(PlayerDropItemEvent event)
{
DropSheep(event.getPlayer(), 500);
DropSheep(event.getPlayer(), 500, true);
}
@EventHandler
@ -558,7 +558,7 @@ public class SheepGame extends TeamGame
Player player = event.GetDamageePlayer();
if (player == null) return;
DropSheep(player, 1000);
DropSheep(player, 1000, false);
Bukkit.getPluginManager().callEvent(new DropEnemySheepEvent(event.GetDamagerPlayer(true), player));
}

View File

@ -1679,4 +1679,21 @@ public class SurvivalGames extends SoloGame
Scoreboard.Draw();
}
@Override
public boolean IsLive()
{
return super.IsLive() && !isDeathMatchAboutToStart();
}
public boolean isDeathMatchAboutToStart()
{
if (!_deathmatchLive)
return false;
if (_deathmatchTime <= 0)
return false;
return true;
}
}

View File

@ -0,0 +1,354 @@
package nautilus.game.arcade.game.games.wither;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.data.BlockData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
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.games.wither.kit.*;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
import nautilus.game.arcade.kit.perks.data.IBlockRestorer;
public class WitherGame extends TeamGame implements IBlockRestorer
{
private GameTeam _runners;
private GameTeam _withers;
private double _witherFactor = 3;
private long _gameTime = 240000;
private int _pointGoal = 50;
private int _points = 0;
private int _witherY = 60;
private Location _spawnA;
private Location _spawnB;
private Location _safeA;
private Location _safeB;
private Location _boatA;
private Location _boatB;
private HashSet<BlockData> _blocks = new HashSet<BlockData>();
public WitherGame(ArcadeManager manager)
{
super(manager, GameType.WitherAssault,
new Kit[]
{
new KitHumanRunner(manager),
new KitHumanBlinder(manager),
new KitHumanRepairman(manager),
new NullKit(manager),
new KitWither(manager),
},
new String[]
{
C.cGreen + "Humans" + C.cWhite + " Escape to the Beacon",
C.cGreen + "Humans" + C.cWhite + " Win by reaching Beacon 100 times",
" ",
C.cRed + "Withers" + C.cWhite + " Stop Humans from reaching the Beacon",
C.cRed + "Withers" + C.cWhite + " Win after 4 Minutes",
});
this.DeathOut = false;
this.DamageTeamSelf = false;
this.DamageSelf = false;
this.HungerSet = 20;
this.KitRegisterState = GameState.Prepare;
}
@Override
public void ParseData()
{
_witherY = WorldData.GetDataLocs("RED").get(0).getBlockY();
_safeA = WorldData.GetDataLocs("YELLOW").get(0);
_safeB = WorldData.GetDataLocs("YELLOW").get(1);
_boatA = WorldData.GetDataLocs("GREEN").get(0);
_boatB = WorldData.GetDataLocs("GREEN").get(1);
_spawnA = WorldData.GetDataLocs("BLUE").get(0);
_spawnB = WorldData.GetDataLocs("BLUE").get(1);
}
@EventHandler
public void teamSetup(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
return;
for (Kit kit : GetKits())
{
for (GameTeam team : GetTeamList())
{
if (team.GetColor() == ChatColor.RED)
{
_withers = team;
_withers.SetName("Withers");
_withers.SetColor(ChatColor.RED);
if (!kit.GetName().contains("Wither"))
team.GetRestrictedKits().add(kit);
}
else
{
_runners = team;
_runners.SetName("Humans");
_runners.SetColor(ChatColor.GREEN);
if (kit.GetName().contains("Wither"))
team.GetRestrictedKits().add(kit);
}
}
}
}
@EventHandler
public void teamBalance(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.FAST)
return;
//Not Enough Players
if (_runners.GetPlayers(true).size() < 2)
return;
//Enough Withers
if (_withers.GetPlayers(true).size() * _witherFactor >= _runners.GetPlayers(true).size())
return;
Player player = UtilAlg.Random(_runners.GetPlayers(true));
setWither(player, true);
}
public void setWither(Player player, boolean forced)
{
SetPlayerTeam(player, _withers, true);
//Kit
Kit newKit = GetKits()[4];
SetKit(player, newKit, false);
newKit.ApplyKit(player);
if (forced)
{
AddGems(player, 10, "Forced Wither", false);
Announce(F.main("Game", F.elem(_withers.GetColor() + player.getName()) + " has become a " +
F.elem(_withers.GetColor() + newKit.GetName()) + "."));
player.getWorld().strikeLightningEffect(player.getLocation());
}
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
//Players Quit
if (GetPlayers(true).size() < 2)
{
SetState(GameState.End);
}
GameTeam winner = null;
//Wither Win
if (UtilTime.elapsed(this.GetStateTime(), _gameTime))
winner = _withers;
//Runner Win
if (_points >= _pointGoal)
winner = _runners;
//Set Win
if (winner != null)
{
AnnounceEnd(_withers);
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
}
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (!InProgress())
return;
if (event.getType() != UpdateType.FAST)
return;
//Wipe Last
Scoreboard.Reset();
Scoreboard.WriteBlank();
Scoreboard.Write(_runners.GetColor() + C.Bold + _runners.GetName());
Scoreboard.Write(_runners.GetColor() + "" + _runners.GetPlayers(true).size() + " Players");
Scoreboard.WriteBlank();
Scoreboard.Write(_withers.GetColor() + C.Bold + _withers.GetName());
Scoreboard.Write(_withers.GetColor() + "" + _withers.GetPlayers(true).size() + " Players");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Escapes");
Scoreboard.Write(_points + " / " + _pointGoal);
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Time Left");
Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _gameTime - (System.currentTimeMillis() - this.GetStateTime())), 1));
Scoreboard.Draw();
}
@Override
public boolean CanJoinTeam(GameTeam team)
{
if (team.equals(_withers))
return team.GetSize() < getRequiredWithers();
return team.GetSize() < GetPlayers(true).size() - getRequiredWithers();
}
public int getRequiredWithers()
{
return (int)(GetPlayers(true).size()/_witherFactor);
}
@EventHandler
public void witherBump(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : _withers.GetPlayers(true))
{
if (player.getLocation().getY() < _witherY)
{
player.setVelocity(new Vector(0, 0.6, 0));
if (Recharge.Instance.use(player, "Wither Bump", 5000, false, false))
UtilPlayer.message(player, F.main("Game", "Withers cannot descend past this point."));
}
}
}
@Override
public void restoreBlock(Location loc, double radius)
{
Iterator<BlockData> dataIt = _blocks.iterator();
while (dataIt.hasNext())
{
BlockData data = dataIt.next();
double dist = UtilMath.offset(loc, data.Block.getLocation().add(0.5, 0.5, 0.5));
if (dist < radius)
{
Manager.GetBlockRestore().Add(data.Block, 0, (byte)0, data.Material.getId(), data.Data, (long) (6000 * (dist/radius)));
dataIt.remove();
}
}
}
@Override
public void addBlocks(Set<Block> blocks)
{
Iterator<Block> blockIter = blocks.iterator();
while (blockIter.hasNext())
{
Block block = blockIter.next();
if (UtilAlg.inBoundingBox(block.getLocation(), _safeA, _safeB) || UtilAlg.inBoundingBox(block.getLocation(), _spawnA, _spawnB))
blockIter.remove();
}
for (Block block : blocks)
_blocks.add(new BlockData(block));
}
@EventHandler
public void boatEscape(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : _runners.GetPlayers(true))
{
if (UtilAlg.inBoundingBox(player.getLocation(), _boatA, _boatB))
{
_points++;
UtilFirework.playFirework(player.getLocation(), Type.BALL, Color.LIME, true, true);
player.teleport(_runners.GetSpawn());
Announce(C.cGreen + C.Bold + player.getName() + " escaped!");
AddGems(player, 4, "Escapes", true);
}
}
}
}

View File

@ -0,0 +1,61 @@
package nautilus.game.arcade.game.games.wither.kit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.PerkWitherArrowBlind;
public class KitHumanBlinder extends Kit
{
public KitHumanBlinder(ArcadeManager manager)
{
super(manager, "Human Blinder", KitAvailability.Free,
new String[]
{
""
},
new Perk[]
{
new PerkWitherArrowBlind(4)
},
EntityType.ZOMBIE,
null);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 8));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
Manager.GetCondition().Factory().Invulnerable("Spawn Invul", player, player, 8, false, false);
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
}
}

View File

@ -0,0 +1,59 @@
package nautilus.game.arcade.game.games.wither.kit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.PerkBlockRestorer;
public class KitHumanRepairman extends Kit
{
public KitHumanRepairman(ArcadeManager manager)
{
super(manager, "Human Repairman", KitAvailability.Free,
new String[]
{
""
},
new Perk[]
{
new PerkBlockRestorer()
},
EntityType.ZOMBIE,
null);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
Manager.GetCondition().Factory().Invulnerable("Spawn Invul", player, player, 8, false, false);
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
}
}

View File

@ -0,0 +1,60 @@
package nautilus.game.arcade.game.games.wither.kit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
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.PerkLeap;
public class KitHumanRunner extends Kit
{
public KitHumanRunner(ArcadeManager manager)
{
super(manager, "Human Leaper", KitAvailability.Free,
new String[]
{
""
},
new Perk[]
{
new PerkLeap("Leap", 1, 1, 4000)
},
EntityType.ZOMBIE,
null);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
Manager.GetCondition().Factory().Invulnerable("Spawn Invul", player, player, 8, false, false);
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
}
}

View File

@ -0,0 +1,119 @@
package nautilus.game.arcade.game.games.wither.kit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseBlaze;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
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.*;
import nautilus.game.arcade.kit.perks.data.IBlockRestorer;
public class KitWither extends Kit
{
public KitWither(ArcadeManager manager)
{
super(manager, "Wither", KitAvailability.Free,
new String[]
{
""
},
new Perk[]
{
new PerkWitherArrows(),
new PerkWitherAttack(),
new PerkWitherWeb(),
new PerkWitherMinion()
},
EntityType.ZOMBIE,
null);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1,
C.cYellow + C.Bold + "Left-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Wither Skull"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1,
C.cYellow + C.Bold + "Left-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Web Blast"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1,
C.cYellow + C.Bold + "Left-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Skeletal Minions"));
//Disguise
DisguiseBlaze disguise = new DisguiseBlaze(player);
if (Manager.GetGame().GetTeam(player) != null)
disguise.SetName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
else
disguise.SetName(player.getName());
disguise.SetCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
}
@EventHandler(priority = EventPriority.LOWEST)
public void witherDamageCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player player = event.GetDamageePlayer();
if (player == null)
return;
if (HasKit(player))
event.SetCancelled("Wither Immunity");
}
@EventHandler(priority = EventPriority.LOWEST)
public void witherMeleeCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player player = event.GetDamagerPlayer(true);
if (player == null)
return;
if (!HasKit(player))
return;
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
return;
event.SetCancelled("Wither Melee Cancel");
}
@EventHandler
public void witherFlight(UpdateEvent event)
{
for (Player player : UtilServer.getPlayers())
{
if (!HasKit(player))
continue;
if (player.isFlying())
continue;
player.setAllowFlight(true);
player.setFlying(true);
player.setFlySpeed(0.1f);
}
}
}

View File

@ -0,0 +1,95 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.data.IBlockRestorer;
public class PerkBlockRestorer extends Perk implements IThrown
{
public PerkBlockRestorer()
{
super("Repair Master", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Throw Repairer",
});
}
@EventHandler
public void Throw(PlayerInteractEvent event)
{
if (!UtilEvent.isAction(event, ActionType.R))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 12000, true, true))
return;
event.setCancelled(true);
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.COMMAND));
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
Manager.GetProjectile().AddThrow(ent, player, this, -1, false, false, true, false, 2d);
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
restore(data.GetThrown());
}
@Override
public void Idle(ProjectileUser data)
{
restore(data.GetThrown());
}
@Override
public void Expire(ProjectileUser data)
{
restore(data.GetThrown());
}
public void restore(Entity entity)
{
if (Manager.GetGame() != null && Manager.GetGame() instanceof IBlockRestorer)
{
((IBlockRestorer)Manager.GetGame()).restoreBlock(entity.getLocation(), 8);
}
entity.remove();
UtilFirework.playFirework(entity.getLocation(), Type.BALL_LARGE, Color.WHITE, false, true);
}
}

View File

@ -282,12 +282,6 @@ public class PerkSlimeRocket extends Perk implements IThrown
if (owner != null && owner.equals(event.GetDamageeEntity()))
{
event.SetCancelled("Owner Damage");
//Heal Owner
if (slime.getVehicle() == null)
{
UtilPlayer.health(owner, 1);
}
}
else
{

View File

@ -0,0 +1,137 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherArrowBlind extends Perk
{
private ArrayList<Arrow> _arrows = new ArrayList<Arrow>();
private int _proximityHit;
public PerkWitherArrowBlind(int proximityHit)
{
super("Smoke Arrow", new String[]
{
"Your arrows give Blindness for 4 seconds"
});
_proximityHit = proximityHit;
}
@EventHandler
public void FireBow(EntityShootBowEvent event)
{
if (!(event.getEntity() instanceof Player))
return;
if (!(event.getProjectile() instanceof Arrow))
return;
Player player = (Player)event.getEntity();
if (!Kit.HasKit(player))
return;
//Start
_arrows.add((Arrow)event.getProjectile());
}
@EventHandler(priority = EventPriority.HIGH)
public void Damage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetProjectile() == null)
return;
if (event.GetDamagerPlayer(true) == null)
return;
if (!(event.GetProjectile() instanceof Arrow))
return;
Arrow arrow = (Arrow)event.GetProjectile();
if (!_arrows.remove(arrow))
return;
Manager.GetCondition().Factory().Blind(GetName(), event.GetDamageeEntity(), null, 4, 0, false, false, false);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, arrow.getLocation(), 0, 0, 0, 0, 1);
event.SetCancelled("Smoke Arrow");
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Iterator<Arrow> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();)
{
Arrow arrow = arrowIterator.next();
//Proxy
if (_proximityHit > 0 && getWitherTeam() != null)
{
boolean hit = false;
for (Player player : getWitherTeam().GetPlayers(true))
{
if (UtilMath.offset(player.getLocation().add(0, 2, 0), arrow.getLocation()) < _proximityHit)
{
Manager.GetCondition().Factory().Blind(GetName(), player, null, 4, 0, false, false, false);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, arrow.getLocation(), 0, 0, 0, 0, 1);
arrowIterator.remove();
arrow.remove();
hit = true;
continue;
}
}
if (hit)
continue;
}
//Dead
if (arrow.isDead() || !arrow.isValid() || arrow.getTicksLived() > 120 || arrow.isOnGround())
{
arrow.remove();
arrowIterator.remove();
}
//Particle
else
{
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, arrow.getLocation(), 0, 0, 0, 0, 1);
}
}
}
public GameTeam getWitherTeam()
{
if (Manager.GetGame() == null)
return null;
return Manager.GetGame().GetTeam(ChatColor.RED);
}
}

View File

@ -0,0 +1,91 @@
package nautilus.game.arcade.kit.perks;
import java.util.Iterator;
import java.util.WeakHashMap;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherArrows extends Perk
{
private WeakHashMap<Arrow, Player> _proj = new WeakHashMap<Arrow, Player>();
public PerkWitherArrows()
{
super("Fire Storm", new String[]
{
C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Fire Storm"
});
}
@EventHandler
public void shoot(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!Kit.HasKit(player))
continue;
if (!player.isBlocking())
{
player.setExp((float) Math.min(0.999, player.getExp()+(1f/40f)));
}
else if (player.getExp() > 0)
{
player.setExp((float) Math.max(0, player.getExp()-(1f/40f)));
for (int i=0 ; i<2 ; i++)
{
Arrow arrow = player.getWorld().spawnArrow(
player.getEyeLocation().add(player.getLocation().getDirection()),
player.getLocation().getDirection(), 2, 12);
arrow.setShooter(player);
_proj.put(arrow, player);
}
//Effect
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.1f, 0.5f);
}
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Arrow> arrowIter = _proj.keySet().iterator();
while (arrowIter.hasNext())
{
Arrow arrow = arrowIter.next();
if (!arrow.isValid() || arrow.getTicksLived() > 60 || arrow.getLocation().getY() < 0)
{
arrow.remove();
arrowIter.remove();
}
else if (arrow.getTicksLived() > 1)
{
UtilParticle.PlayParticle(ParticleType.FLAME, arrow.getLocation(), 0, 0, 0, 0, 1);
}
}
}
}

View File

@ -0,0 +1,175 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityExplodeEvent;
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.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.data.IBlockRestorer;
public class PerkWitherAttack extends Perk
{
private ArrayList<WitherSkull> _active = new ArrayList<WitherSkull>();
public PerkWitherAttack()
{
super("Wither Skull", new String[]
{
C.cYellow + "Left-Click" + C.cGray + " with Gold Sword to use " + C.cGreen + "Wither Skull"
});
}
@EventHandler
public void Activate(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.GOLD_SWORD))
return;
if (!Recharge.Instance.use(player, GetName(), 2000, true, true))
return;
//Fire
_active.add(player.launchProjectile(WitherSkull.class));
//Sound
player.getWorld().playSound(player.getLocation(), Sound.WITHER_SHOOT, 1f, 1f);
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}
@EventHandler
public void explode(EntityExplodeEvent event)
{
if (!_active.contains(event.getEntity()))
return;
event.setCancelled(true);
WitherSkull skull = (WitherSkull)event.getEntity();
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1);
explode(skull);
}
@EventHandler
public void clean(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Iterator<WitherSkull> skullIterator = _active.iterator();
while (skullIterator.hasNext())
{
WitherSkull skull = skullIterator.next();
if (!skull.isValid())
{
skullIterator.remove();
skull.remove();
continue;
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void ExplodeDamage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetProjectile() != null && event.GetProjectile() instanceof WitherSkull)
event.SetCancelled("Wither Skull Cancel");
}
private void explode(WitherSkull skull)
{
double scale = 0.4 + 0.6 * Math.min(1, skull.getTicksLived()/20d);
//Players
HashMap<Player, Double> players = UtilPlayer.getInRadius(skull.getLocation(), 6);
for (Player player : players.keySet())
{
if (!Manager.GetGame().IsAlive(player))
continue;
//Damage Event
Manager.GetDamage().NewDamageEvent(player, (LivingEntity)skull.getShooter(), null,
DamageCause.CUSTOM, 10 * scale, true, true, false,
UtilEnt.getName((LivingEntity)skull.getShooter()), GetName());
}
//Blocks
Set<Block> blocks = UtilBlock.getInRadius(skull.getLocation(), 4d).keySet();
Iterator<Block> blockIterator = blocks.iterator();
while (blockIterator.hasNext())
{
Block block = blockIterator.next();
if (block.isLiquid())
blockIterator.remove();
else if (block.getRelative(BlockFace.UP).isLiquid())
blockIterator.remove();
}
if (Manager.GetGame() != null && Manager.GetGame() instanceof IBlockRestorer)
{
((IBlockRestorer)Manager.GetGame()).addBlocks(blocks);
}
Manager.GetExplosion().BlockExplosion(blocks, skull.getLocation(), false);
}
}

View File

@ -0,0 +1,170 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
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.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherMinion extends Perk
{
private ArrayList<Skeleton> _ents = new ArrayList<Skeleton>();
public PerkWitherMinion()
{
super("Wither Minions", new String[]
{
C.cYellow + "Left-Click" + C.cGray + " with Diamond Sword to use " + C.cGreen + "Wither Minions"
});
}
@EventHandler
public void ShootWeb(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.DIAMOND_SWORD))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 10000, true, true))
return;
event.setCancelled(true);
Manager.GetGame().CreatureAllowOverride = true;
for (int i=0 ; i<3 ; i++)
{
Skeleton skel = player.getWorld().spawn(player.getEyeLocation(), Skeleton.class);
_ents.add(skel);
skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)1, 1));
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(Color.BLACK);
armor.setItemMeta(meta);
skel.getEquipment().setChestplate(armor);
Manager.GetCondition().Factory().Invisible("Skeleton", skel, skel, 9999, 0, false, false, false);
Manager.GetCondition().Factory().Speed("Skeleton", skel, skel, 9999, 0, false, false, false);
Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
random.normalize();
random.multiply(0.1);
UtilAction.velocity(skel, player.getLocation().getDirection().add(random), 1 + Math.random() * 0.4, false, 0, 0.2, 10, false);
}
Manager.GetGame().CreatureAllowOverride = false;
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.WITHER_HURT, 2f, 0.6f);
}
@EventHandler(priority = EventPriority.LOWEST)
public void witherMeleeCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() != DamageCause.FALL)
return;
if (_ents.contains(event.GetDamageeEntity()))
return;
event.SetCancelled("Minion Fall Damage");
}
@EventHandler
public void entityTarget(EntityTargetEvent event)
{
if (getWitherTeam() == null)
return;
if (getWitherTeam().GetPlayers(true).contains(event.getTarget()))
event.setCancelled(true);
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Skeleton> skelIter = _ents.iterator();
while (skelIter.hasNext())
{
Skeleton skel = skelIter.next();
if (!skel.isValid() || skel.getTicksLived() > 300 || skel.getLocation().getY() < 0)
{
skel.remove();
skelIter.remove();
}
else
{
if (skel.getTarget() == null)
{
skel.setTarget(UtilPlayer.getClosest(skel.getLocation(), getWitherTeam().GetPlayers(true)));
}
}
}
}
public GameTeam getWitherTeam()
{
if (Manager.GetGame() == null)
return null;
return Manager.GetGame().GetTeam(ChatColor.RED);
}
}

View File

@ -0,0 +1,111 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.Location;
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 org.bukkit.util.Vector;
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.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherWeb extends Perk implements IThrown
{
public PerkWitherWeb()
{
super("Web Blast", new String[]
{
C.cYellow + "Left-Click" + C.cGray + " with Iron Sword to use " + C.cGreen + "Web Blast"
});
}
@EventHandler
public void ShootWeb(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.IRON_SWORD))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 6000, true, true))
return;
event.setCancelled(true);
for (int i=0 ; i<40 ; i++)
{
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.WEB));
Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
random.normalize();
random.multiply(0.25);
UtilAction.velocity(ent, player.getLocation().getDirection().add(random), 1 + Math.random() * 0.4, false, 0, 0.2, 10, false);
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 2d);
}
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.WITHER_HURT, 2f, 0.6f);
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Web(data);
}
@Override
public void Idle(ProjectileUser data)
{
Web(data);
}
@Override
public void Expire(ProjectileUser data)
{
Web(data);
}
public void Web(ProjectileUser data)
{
Location loc = data.GetThrown().getLocation();
data.GetThrown().remove();
if (data.GetThrown().getTicksLived() > 3)
Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 3000);
}
}

View File

@ -0,0 +1,12 @@
package nautilus.game.arcade.kit.perks.data;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.block.Block;
public interface IBlockRestorer
{
public void restoreBlock(Location loc, double radius);
public void addBlocks(Set<Block> blocks);
}

View File

@ -1,5 +1,11 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -8,6 +14,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.CombatDamage;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageChange;
import nautilus.game.arcade.game.Game;
@ -15,13 +22,42 @@ public class KillReasonStatTracker extends StatTracker<Game>
{
private final String _reason;
private final String _statName;
private final boolean _canBeDamagedByKilledPlayer;
private final Map<UUID, Set<UUID>> _damaged = new HashMap<>();
public KillReasonStatTracker(Game game, String reason, String statName)
public KillReasonStatTracker(Game game, String reason, String statName, boolean canBeDamagedByKilledPlayer)
{
super(game);
_reason = reason;
_statName = statName;
_canBeDamagedByKilledPlayer = canBeDamagedByKilledPlayer;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCustomDamage(CustomDamageEvent event)
{
if (canBeDamagedByKilledPlayer())
return;
if (getGame().GetState() != Game.GameState.Live)
return;
Player damager = event.GetDamagerPlayer(false);
if (damager == null)
return;
Player damagee = event.GetDamageePlayer();
if (damagee == null)
return;
Set<UUID> set = _damaged.get(damagee.getUniqueId());
if (set == null)
{
set = new HashSet<>();
_damaged.put(damagee.getUniqueId(), set);
}
set.add(damager.getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@ -50,6 +86,13 @@ public class KillReasonStatTracker extends StatTracker<Game>
if (player == null)
return;
if (!canBeDamagedByKilledPlayer())
{
Set<UUID> set = _damaged.remove(killer.getUniqueId());
if (set != null && set.contains(player.getUniqueId()))
return;
}
if (event.GetLog().GetLastDamager() != null && event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains(getReason()))
addStat(killer, getStatName(), 1, false, false);
else
@ -84,4 +127,9 @@ public class KillReasonStatTracker extends StatTracker<Game>
{
return _reason;
}
public boolean canBeDamagedByKilledPlayer()
{
return _canBeDamagedByKilledPlayer;
}
}