Move perks into SkywarsPerks for less copied code

This commit is contained in:
Sam 2018-01-08 14:46:06 +00:00 committed by Alexander Meech
parent e5a5b87abc
commit 60cdae5c04
24 changed files with 691 additions and 983 deletions

View File

@ -90,8 +90,6 @@ import nautilus.game.arcade.game.games.skyfall.SoloSkyfall;
import nautilus.game.arcade.game.games.skyfall.TeamSkyfall; import nautilus.game.arcade.game.games.skyfall.TeamSkyfall;
import nautilus.game.arcade.game.games.skywars.SoloSkywars; import nautilus.game.arcade.game.games.skywars.SoloSkywars;
import nautilus.game.arcade.game.games.skywars.TeamSkywars; import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.game.games.skywars.modes.Elementalist;
import nautilus.game.arcade.game.games.skywars.modes.OverpoweredSkywars;
import nautilus.game.arcade.game.games.skywars.modes.SkySmash; import nautilus.game.arcade.game.games.skywars.modes.SkySmash;
import nautilus.game.arcade.game.games.skywars.modes.UHCSkywars; import nautilus.game.arcade.game.games.skywars.modes.UHCSkywars;
import nautilus.game.arcade.game.games.smash.SoloSuperSmash; import nautilus.game.arcade.game.games.smash.SoloSuperSmash;
@ -276,10 +274,8 @@ public enum GameType
new GameMode(OverpoweredGladiators.class, GameType.Gladiators, "OP Gladiators"), new GameMode(OverpoweredGladiators.class, GameType.Gladiators, "OP Gladiators"),
new GameMode(ChampionsGladiators.class, GameType.Gladiators, "Champions Gladiators"), new GameMode(ChampionsGladiators.class, GameType.Gladiators, "Champions Gladiators"),
new GameMode(SmashGladiators.class, GameType.Gladiators, "Smash Gladiators"), new GameMode(SmashGladiators.class, GameType.Gladiators, "Smash Gladiators"),
new GameMode(OverpoweredSkywars.class, GameType.Skywars, "OP Skywars"),
new GameMode(UHCSkywars.class, GameType.Skywars, "UHC Skywars"), new GameMode(UHCSkywars.class, GameType.Skywars, "UHC Skywars"),
new GameMode(SkySmash.class, GameType.Skywars, "Sky Smash"), new GameMode(SkySmash.class, GameType.Skywars, "Sky Smash"),
new GameMode(Elementalist.class, GameType.Skywars, "Elementalist"),
new GameMode(TeamBuild.class, GameType.Build, "Team Master Builders"), new GameMode(TeamBuild.class, GameType.Build, "Team Master Builders"),
new GameMode(DukesOfDecoration.class, GameType.Build, "Dukes Of Decoration"), new GameMode(DukesOfDecoration.class, GameType.Build, "Dukes Of Decoration"),
new GameMode(GodBattles.class, GameType.UHC, "God Battles"), new GameMode(GodBattles.class, GameType.UHC, "God Battles"),

View File

@ -7,6 +7,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -24,11 +25,13 @@ import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.explosion.ExplosionEvent; import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.itemstack.EnchantedBookBuilder; import mineplex.core.itemstack.EnchantedBookBuilder;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -64,7 +67,7 @@ public abstract class Skywars extends Game
{ {
// ./parse 19 30 56 // ./parse 19 30 56
private long _crumbleTime = 150000; private static final long CRUMBLE_TIME = TimeUnit.SECONDS.toMillis(100);
private OreHider _oreHider; private OreHider _oreHider;
@ -137,15 +140,23 @@ public abstract class Skywars extends Game
new EXPForKillsModule() new EXPForKillsModule()
.register(this); .register(this);
manager.GetCreature().SetDisableCustomDrops(true);
} }
@Override @Override
public void ParseData() public void ParseData()
{ {
parseCreatePlayerWebs();
new MapCrumbleModule() new MapCrumbleModule()
.setEnabled(true) .setEnableAfter(CRUMBLE_TIME, () ->
{
Announce(C.cGreenB + "The world begins to crumble...", false);
for (Player player : UtilServer.getPlayersCollection())
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1);
}
})
.register(this); .register(this);
new ZombieGuardianModule() new ZombieGuardianModule()
@ -182,7 +193,7 @@ public abstract class Skywars extends Game
setupLoot(); setupLoot();
} }
protected void setupLoot() private void setupLoot()
{ {
new ChestLootModule() new ChestLootModule()
.registerChestType("Island", WorldData.GetDataLocs("BROWN"), .registerChestType("Island", WorldData.GetDataLocs("BROWN"),
@ -355,6 +366,7 @@ public abstract class Skywars extends Game
.addItem(new ItemStack(Material.LAVA_BUCKET), 80) .addItem(new ItemStack(Material.LAVA_BUCKET), 80)
.addItem(new ItemStack(Material.WATER_BUCKET)) .addItem(new ItemStack(Material.WATER_BUCKET))
.addItem(new ItemStack(Material.ENDER_PEARL), 1, 2) .addItem(new ItemStack(Material.ENDER_PEARL), 1, 2)
.addItem(new ItemStack(Material.MUSHROOM_SOUP))
.setAmountsPerChest(1, 2) .setAmountsPerChest(1, 2)
.setProbability(0.8), .setProbability(0.8),
@ -377,46 +389,6 @@ public abstract class Skywars extends Game
.build(); .build();
} }
private void parseCreatePlayerWebs()
{
// Store which chests are closest to which spawn
NautHashMap<Location, ArrayList<Location>> islandWebs = new NautHashMap<Location, ArrayList<Location>>();
// Allocate chests to their nearest spawn point
for (Location webLoc : WorldData.GetCustomLocs("30"))
{
// Gets the spawn point closest to the current chest
Location closestSpawn = UtilAlg.findClosest(webLoc, GetTeamList().get(0).GetSpawns());
if (UtilMath.offset2d(webLoc, closestSpawn) > 8)
continue;
// Ensure the list exists
if (!islandWebs.containsKey(closestSpawn))
islandWebs.put(closestSpawn, new ArrayList<Location>());
// Add this chest location to the spawn
islandWebs.get(closestSpawn).add(webLoc);
}
// Create 2 Webs
for (ArrayList<Location> webs : islandWebs.values())
{
for (int i = 0; i < 2; i++)
{
if (!webs.isEmpty())
{
webs.remove(UtilAlg.Random(webs));
}
}
for (Location loc : webs)
{
loc.getBlock().setType(Material.AIR);
}
}
}
@EventHandler @EventHandler
public void informLeapCooldown(GameStateChangeEvent event) public void informLeapCooldown(GameStateChangeEvent event)
{ {
@ -425,7 +397,7 @@ public abstract class Skywars extends Game
return; return;
} }
String message = F.main("Game", "Your " + F.skill("Leap") + " is on a 30 second cooldown."); String message = F.main("Game", "Your " + F.skill("Leap") + " is on a " + F.time("20 second") + " cooldown.");
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
@ -434,7 +406,7 @@ public abstract class Skywars extends Game
if (kit instanceof KitAir || kit instanceof KitElementalist) if (kit instanceof KitAir || kit instanceof KitElementalist)
{ {
player.sendMessage(message); player.sendMessage(message);
Recharge.Instance.use(player, "Leap", 30000, true, false); Recharge.Instance.use(player, "Leap", 20000, true, false);
} }
} }
} }
@ -510,25 +482,25 @@ public abstract class Skywars extends Game
} }
@EventHandler @EventHandler
public void onBlockBurn(BlockBurnEvent event) public void blockBurn(BlockBurnEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onBlockDecay(LeavesDecayEvent event) public void blockDecay(LeavesDecayEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onBlockFade(BlockFadeEvent event) public void blockFade(BlockFadeEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onBlockSpread(BlockSpreadEvent event) public void blockSpread(BlockSpreadEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -558,33 +530,30 @@ public abstract class Skywars extends Game
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreakBonusDrops(BlockBreakEvent event) public void blockBreakBonusDrops(BlockBreakEvent event)
{ {
event.setExpToDrop(0); event.setExpToDrop(0);
Block block = event.getBlock(); Block block = event.getBlock();
ItemStack toDrop = null;
if (block.getType() == Material.WEB) switch (block.getType())
{ {
event.setCancelled(true); case WEB:
block.setType(Material.AIR); toDrop = new ItemStack(Material.STRING, 1 + UtilMath.r(2));
break;
for (int i = 0; i < 1 + UtilMath.r(2); i++) case GRAVEL:
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.STRING)); toDrop = new ItemStack(Material.FLINT, 1 + UtilMath.r(3));
break;
case IRON_ORE:
toDrop = new ItemStack(Material.IRON_INGOT);
break;
} }
else if (block.getType() == Material.GRAVEL)
{
event.setCancelled(true);
block.setType(Material.AIR);
for (int i = 0; i < 1 + UtilMath.r(3); i++) if (toDrop != null)
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.FLINT));
}
else if (block.getType() == Material.IRON_ORE)
{ {
event.setCancelled(true); event.setCancelled(true);
block.setType(Material.AIR); block.breakNaturally(toDrop);
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.IRON_INGOT));
} }
} }
@ -609,73 +578,33 @@ public abstract class Skywars extends Game
// } // }
@EventHandler @EventHandler
public void onBlockBreakTNTSpawner(BlockBreakEvent event) public void projectileDamage(CustomDamageEvent event)
{
Material material = event.getBlock().getType();
if (material == Material.IRON_BLOCK || material == Material.REDSTONE_BLOCK)
{
event.setCancelled(true);
}
}
@EventHandler
public void onCustomDamageToLevel(CustomDamageEvent event)
{ {
event.SetDamageToLevel(false); event.SetDamageToLevel(false);
}
//TODO REIMPLEMENT if (!IsLive() || event.GetProjectile() == null)
// @EventHandler
// public void onEntityDeathMobLoot(EntityDeathEvent event)
// {
// // Zombie Loot
// if (event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie) event.getEntity()))
// {
// event.getDrops().clear();
//
// double r = Math.random();
//
// if (r > 0.80)
// event.getDrops().add(_middleArmor.getLoot());
// else if (r > 0.60)
// event.getDrops().add(_middleTool.getLoot());
// else if (r > 0.40)
// event.getDrops().add(_middleProjectile.getLoot());
// else
// event.getDrops().add(_middleFood.getLoot());
// }
// // Chicken Loot
// else if (event.getEntity() instanceof Chicken)
// {
// event.getDrops().clear();
//
// event.getDrops().add(new ItemStack(Material.FEATHER, 1 + UtilMath.r(4)));
// }
// }
@EventHandler
public void onCustomDamageProjectile(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
{ {
return; return;
} }
if (event.GetProjectile() instanceof Egg || event.GetProjectile() instanceof Snowball) boolean egg = event.GetProjectile() instanceof Egg;
boolean snowball = event.GetProjectile() instanceof Snowball;
if (egg || snowball)
{ {
event.AddMod(event.GetDamagerPlayer(true).getName(), (event.GetProjectile() instanceof Egg ? "Egg" : "Snowball"), 0.5, true); event.AddMod(event.GetDamagerPlayer(true).getName(), (egg ? "Egg" : "Snowball"), 0.5, true);
} }
} }
@EventHandler @EventHandler
public void onExplosion(ExplosionEvent event) public void explosion(ExplosionEvent event)
{ {
_oreHider.Explosion(event); _oreHider.Explosion(event);
event.GetBlocks().removeIf(block -> block.getType() == Material.CHEST || block.getType() == Material.ANVIL); event.GetBlocks().removeIf(block -> block.getType() == Material.CHEST || block.getType() == Material.ANVIL);
} }
@EventHandler @EventHandler
public void onBlockBreakOreReveal(BlockBreakEvent event) public void blockBreakOreReveal(BlockBreakEvent event)
{ {
_oreHider.BlockBreak(event); _oreHider.BlockBreak(event);
} }

View File

@ -3,16 +3,20 @@ package nautilus.game.arcade.game.games.skywars.kits;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDoubleJump; import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkVoidSaver; import nautilus.game.arcade.game.games.skywars.kits.perks.PerkVoidSaver;
public class KitAir extends ProgressingKit public class KitAir extends ProgressingKit
{ {
@ -29,31 +33,35 @@ public class KitAir extends ProgressingKit
C.cYellow + "Tap Jump Twice" + C.cWhite + " to " + C.cGreen + DOUBLE_JUMP, C.cYellow + "Tap Jump Twice" + C.cWhite + " to " + C.cGreen + DOUBLE_JUMP,
}; };
private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.EYE_OF_ENDER)
.setTitle(C.cGreen + "Eye of Ender")
.build();
private static final Perk[][] PERKS = private static final Perk[][] PERKS =
{ {
{ {
new PerkVoidSaver(), new PerkVoidSaver(SKILL_ITEM),
new PerkDoubleJump(DOUBLE_JUMP, 1, 1, true, 30000, true) new PerkDoubleJump(DOUBLE_JUMP, 1, 1, true, 25000, true)
}, },
{ {
new PerkVoidSaver(), new PerkVoidSaver(SKILL_ITEM),
new PerkDoubleJump(DOUBLE_JUMP, 1, 1, true, 29000, true) new PerkDoubleJump(DOUBLE_JUMP, 1, 1, true, 24000, true)
}, },
{ {
new PerkVoidSaver(), new PerkVoidSaver(SKILL_ITEM),
new PerkDoubleJump(DOUBLE_JUMP, 1.1, 1, true, 29000, true) new PerkDoubleJump(DOUBLE_JUMP, 1.1, 1, true, 23000, true)
}, },
{ {
new PerkVoidSaver(), new PerkVoidSaver(SKILL_ITEM),
new PerkDoubleJump(DOUBLE_JUMP, 1.1, 1, true, 28000, true) new PerkDoubleJump(DOUBLE_JUMP, 1.1, 1, true, 22000, true)
}, },
{ {
new PerkVoidSaver(), new PerkVoidSaver(SKILL_ITEM),
new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 28000, true) new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 21000, true)
}, },
{ {
new PerkVoidSaver(), new PerkVoidSaver(SKILL_ITEM),
new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 27000, true) new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 20000, true)
}, },
}; };
@ -76,7 +84,7 @@ public class KitAir extends ProgressingKit
}, },
}; };
private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemBuilder(Material.EYE_OF_ENDER).setTitle(C.cGreen + "Eye of Ender").build() }; private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), SKILL_ITEM };
private static final ItemStack IN_HAND = new ItemStack(Material.EYE_OF_ENDER); private static final ItemStack IN_HAND = new ItemStack(Material.EYE_OF_ENDER);
@ -97,4 +105,20 @@ public class KitAir extends ProgressingKit
return true; return true;
} }
@EventHandler
public void fallDamage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.FALL)
{
return;
}
Player player = event.GetDamageePlayer();
if (HasKit(player))
{
event.SetCancelled("Air Kit Fall Damage");
}
}
} }

View File

@ -9,12 +9,13 @@ import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skywars.kits.perks.PerkDirtCannon;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDirtCannon;
import nautilus.game.arcade.kit.perks.PerkKnockback;
public class KitEarth extends ProgressingKit public class KitEarth extends ProgressingKit
{ {
@ -28,34 +29,33 @@ public class KitEarth extends ProgressingKit
"You take " + C.cGreen + "25" + C.cWhite + "% knockback while on the ground." "You take " + C.cGreen + "25" + C.cWhite + "% knockback while on the ground."
}; };
private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.DIRT)
.setTitle(C.cGreen + "Throwable Dirt")
.setGlow(true)
.build();
private static final String DIRT_CANNON = "Throwable Dirt"; private static final String DIRT_CANNON = "Throwable Dirt";
private static final String KNOCKBACK = "Knockback"; private static final String KNOCKBACK = "Knockback";
private static final Perk[][] PERKS = private static final Perk[][] PERKS =
{ {
{ {
new PerkDirtCannon(1), new PerkDirtCannon(SKILL_ITEM, 1),
new PerkKnockback(0.75, true)
}, },
{ {
new PerkDirtCannon(1.1), new PerkDirtCannon(SKILL_ITEM, 1.1),
new PerkKnockback(0.75, true)
}, },
{ {
new PerkDirtCannon(1.2), new PerkDirtCannon(SKILL_ITEM, 1.2),
new PerkKnockback(0.75, true)
}, },
{ {
new PerkDirtCannon(1.3), new PerkDirtCannon(SKILL_ITEM, 1.3),
new PerkKnockback(0.75, true)
}, },
{ {
new PerkDirtCannon(1.4), new PerkDirtCannon(SKILL_ITEM, 1.4),
new PerkKnockback(0.75, true)
}, },
{ {
new PerkDirtCannon(1.5), new PerkDirtCannon(SKILL_ITEM, 1.5),
new PerkKnockback(0.75, true)
}, },
}; };

View File

@ -4,16 +4,19 @@ import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skywars.kits.perks.PerkFireBurst;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkFireBurst;
public class KitFire extends ProgressingKit public class KitFire extends ProgressingKit
{ {
@ -24,30 +27,34 @@ public class KitFire extends ProgressingKit
C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst", C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst",
"Sends out a pulse of fire that deals " + C.cGreen + 5 + C.cWhite + " damage to", "Sends out a pulse of fire that deals " + C.cGreen + 5 + C.cWhite + " damage to",
"all players within " + C.cGreen + 4 + C.cWhite + " blocks.", "all players within " + C.cGreen + 4 + C.cWhite + " blocks.",
"Cooldown " + C.cGreen + UtilTime.convertString(40000, 0, TimeUnit.SECONDS) + C.cWhite + "." "Cooldown " + C.cGreen + UtilTime.convertString(30000, 0, TimeUnit.SECONDS) + C.cWhite + "."
}; };
private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.BLAZE_ROD)
.setTitle(C.cGreen + "Fire Burst")
.build();
private static final String FIRE_BURST = "Fire Burst"; private static final String FIRE_BURST = "Fire Burst";
private static final Perk[][] PERKS = private static final Perk[][] PERKS =
{ {
{ {
new PerkFireBurst(40000, 4, 5) new PerkFireBurst(SKILL_ITEM, 30000, 6, 6)
}, },
{ {
new PerkFireBurst(39000, 4, 5) new PerkFireBurst(SKILL_ITEM, 29000, 6, 6)
}, },
{ {
new PerkFireBurst(38000, 4, 5) new PerkFireBurst(SKILL_ITEM, 28000, 6, 6)
}, },
{ {
new PerkFireBurst(37000, 4, 6) new PerkFireBurst(SKILL_ITEM, 27000, 6, 6)
}, },
{ {
new PerkFireBurst(36000, 4, 6) new PerkFireBurst(SKILL_ITEM, 26000, 6, 6)
}, },
{ {
new PerkFireBurst(35000, 4, 6) new PerkFireBurst(SKILL_ITEM, 25000, 6, 6)
}, },
}; };
@ -61,7 +68,6 @@ public class KitFire extends ProgressingKit
}, },
{ {
reduceCooldown(FIRE_BURST, 1), reduceCooldown(FIRE_BURST, 1),
increase(FIRE_BURST, "Damage", 25)
}, },
{ {
reduceCooldown(FIRE_BURST, 1) reduceCooldown(FIRE_BURST, 1)
@ -72,20 +78,22 @@ public class KitFire extends ProgressingKit
}; };
private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemBuilder(Material.BLAZE_ROD).setTitle(C.cGreen + "Fire Burst").build() }; private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), SKILL_ITEM };
private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD);
private static final PotionEffect FIRE_RESISTANCE = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, false, false);
public KitFire(ArcadeManager manager) public KitFire(ArcadeManager manager)
{ {
super(manager, "Fire", "skywarsminer", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); super(manager, "Fire", "skywarsminer", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
} }
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().addItem(PLAYER_ITEMS);
player.addPotionEffect(FIRE_RESISTANCE);
} }
@Override @Override

View File

@ -13,7 +13,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkIceBridge; import nautilus.game.arcade.game.games.skywars.kits.perks.PerkIceBridge;
public class KitIce extends ProgressingKit public class KitIce extends ProgressingKit
{ {
@ -26,27 +26,31 @@ public class KitIce extends ProgressingKit
"Cooldown " + C.cGreen + UtilTime.convertString(30000, 0, TimeUnit.SECONDS) + C.cWhite + "." "Cooldown " + C.cGreen + UtilTime.convertString(30000, 0, TimeUnit.SECONDS) + C.cWhite + "."
}; };
private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.ICE)
.setTitle(C.cGreen + "Ice Bridge")
.build();
private static final String ICE_BRIDGE = "Ice Bridge"; private static final String ICE_BRIDGE = "Ice Bridge";
private static final Perk[][] PERKS = private static final Perk[][] PERKS =
{ {
{ {
new PerkIceBridge(30000, 4000) new PerkIceBridge(SKILL_ITEM, 30000, 4000)
}, },
{ {
new PerkIceBridge(29000, 4000) new PerkIceBridge(SKILL_ITEM, 29000, 4000)
}, },
{ {
new PerkIceBridge(28000, 5000) new PerkIceBridge(SKILL_ITEM, 28000, 5000)
}, },
{ {
new PerkIceBridge(27000, 5000) new PerkIceBridge(SKILL_ITEM, 27000, 5000)
}, },
{ {
new PerkIceBridge(26000, 6000) new PerkIceBridge(SKILL_ITEM, 26000, 6000)
}, },
{ {
new PerkIceBridge(25000, 6000) new PerkIceBridge(SKILL_ITEM, 25000, 6000)
}, },
}; };
@ -71,7 +75,7 @@ public class KitIce extends ProgressingKit
}, },
}; };
private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemBuilder(Material.ICE).setTitle(C.cGreen + "Ice Bridge").build() }; private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), SKILL_ITEM };
private static final ItemStack IN_HAND = new ItemStack(Material.ICE); private static final ItemStack IN_HAND = new ItemStack(Material.ICE);

View File

@ -13,7 +13,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkMagnetism; import nautilus.game.arcade.game.games.skywars.kits.perks.PerkMagnetism;
public class KitMetal extends ProgressingKit public class KitMetal extends ProgressingKit
{ {
@ -26,36 +26,38 @@ public class KitMetal extends ProgressingKit
C.cGreen + C.Italics + "Metal" + C.cGray + C.Italics + " means Gold/Chainmail/Iron armor.", C.cGreen + C.Italics + "Metal" + C.cGray + C.Italics + " means Gold/Chainmail/Iron armor.",
"", "",
"Any player in your line of sight is drawn to you.", "Any player in your line of sight is drawn to you.",
"The velocity that they are drawn towards you is",
"based on how much metal armor they are wearing",
"Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".", "Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".",
"", "",
"For each piece of metal armor you wear you gain", "For each piece of metal armor you wear you gain",
"an additional " + C.cGreen + "0.5" + C.cWhite + " hearts.", "an additional " + C.cGreen + "0.5" + C.cWhite + " hearts.",
}; };
private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.REDSTONE_COMPARATOR)
.setTitle(C.cGreen + "Magnet")
.build();
private static final String MAGNET = "Magnet"; private static final String MAGNET = "Magnet";
private static final String POWER = "Power"; private static final String POWER = "Power";
private static final Perk[][] PERKS = private static final Perk[][] PERKS =
{ {
{ {
new PerkMagnetism(15000, 10, 1) new PerkMagnetism(SKILL_ITEM, 15000, 12, 1)
}, },
{ {
new PerkMagnetism(15000, 10, 1.1) new PerkMagnetism(SKILL_ITEM, 15000, 12, 1.1)
}, },
{ {
new PerkMagnetism(15000, 10, 1.2) new PerkMagnetism(SKILL_ITEM, 15000, 12, 1.2)
}, },
{ {
new PerkMagnetism(15000, 10, 1.3) new PerkMagnetism(SKILL_ITEM, 15000, 12, 1.3)
}, },
{ {
new PerkMagnetism(15000, 10, 1.4) new PerkMagnetism(SKILL_ITEM, 15000, 12, 1.4)
}, },
{ {
new PerkMagnetism(15000, 10, 1.5) new PerkMagnetism(SKILL_ITEM, 15000, 12, 1.5)
}, },
}; };
@ -78,7 +80,7 @@ public class KitMetal extends ProgressingKit
}, },
}; };
private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemStack(Material.STONE_PICKAXE), new ItemBuilder(Material.REDSTONE_COMPARATOR).setTitle(C.cGreen + "Magnet").build() }; private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemStack(Material.STONE_PICKAXE), SKILL_ITEM };
private static final ItemStack IN_HAND = new ItemStack(Material.REDSTONE_COMPARATOR); private static final ItemStack IN_HAND = new ItemStack(Material.REDSTONE_COMPARATOR);

View File

@ -1,6 +1,4 @@
package nautilus.game.arcade.kit.perks; package nautilus.game.arcade.game.games.skywars.kits.perks;
import java.util.Iterator;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -8,17 +6,11 @@ import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -28,78 +20,57 @@ import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.kit.Perk;
public class PerkDirtCannon extends Perk implements IThrown import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
public class PerkDirtCannon extends SkywarsPerk implements IThrown
{ {
private static final int GIVE_DELAY = 20000; private static final int GIVE_DELAY = 20000;
private static final int MAX_DIRT = 4; private static final int MAX_DIRT = 4;
private static final long COOLDOWN = 500; private static final long COOLDOWN = 500;
private static final ItemStack DIRT_ITEM = new ItemBuilder(Material.DIRT).setTitle(C.cGreen + "Throwable Dirt").setGlow(true).build();
private long _lastDirt; private long _lastDirt;
private double _targetKnockback; private double _targetKnockback;
public PerkDirtCannon(double targetKnockback) public PerkDirtCannon(ItemStack itemStack, double targetKnockback)
{ {
super("Throwable Dirt", new String[] { super("Throwable Dirt", itemStack);
});
_targetKnockback = targetKnockback; _targetKnockback = targetKnockback;
_lastDirt = 0; _lastDirt = 0;
} }
@EventHandler @Override
public void onPlayerInteract(PlayerInteractEvent event) public void onUseItem(Player player)
{ {
if (event.getAction() != Action.RIGHT_CLICK_AIR)
{
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
{
return;
}
if (!DIRT_ITEM.isSimilar(player.getItemInHand()))
{
return;
}
if (!hasPerk(player))
{
return;
}
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true))
{ {
return; return;
} }
int amount = player.getInventory().getItemInHand().getAmount() - 1; player.setItemInHand(UtilInv.decrement(player.getItemInHand()));
if (amount == 0)
{
player.getInventory().remove(DIRT_ITEM);
}
else
{
player.getItemInHand().setAmount(Math.min(MAX_DIRT - 1, amount));
}
@SuppressWarnings("deprecation")
FallingBlock fallingBlock = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.DIRT, (byte) 0); FallingBlock fallingBlock = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.DIRT, (byte) 0);
fallingBlock.setDropItem(false); fallingBlock.setDropItem(false);
fallingBlock.setVelocity(player.getLocation().getDirection().multiply(2)); fallingBlock.setVelocity(player.getLocation().getDirection().multiply(2));
Manager.GetProjectile().AddThrow(fallingBlock, player, this, -1, true, true, true, true, false, 1); Manager.GetProjectile().AddThrow(fallingBlock, player, this, -1, true, true, true, true, false, 1);
} }
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
_lastDirt = System.currentTimeMillis();
}
@EventHandler @EventHandler
public void onUpdate(UpdateEvent event) public void onUpdate(UpdateEvent event)
{ {
@ -117,7 +88,7 @@ public class PerkDirtCannon extends Perk implements IThrown
continue; continue;
} }
player.getInventory().addItem(DIRT_ITEM); player.getInventory().addItem(_itemStack);
} }
_lastDirt = System.currentTimeMillis(); _lastDirt = System.currentTimeMillis();
@ -133,56 +104,6 @@ public class PerkDirtCannon extends Perk implements IThrown
} }
} }
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if (!hasPerk(event.getPlayer()))
{
return;
}
if (DIRT_ITEM.isSimilar(event.getItemInHand()))
{
event.getPlayer().sendMessage(F.main("Game", "You cannot place your skill item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!hasPerk(event.getPlayer()))
{
return;
}
if (DIRT_ITEM.isSimilar(event.getItemDrop().getItemStack()))
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
if (!hasPerk(event.getEntity()))
{
return;
}
Iterator<ItemStack> iterator = event.getDrops().iterator();
while (iterator.hasNext())
{
ItemStack itemStack = iterator.next();
if (DIRT_ITEM.isSimilar(itemStack))
{
iterator.remove();
}
}
}
@Override @Override
public void Collide(LivingEntity target, Block block, ProjectileUser data) public void Collide(LivingEntity target, Block block, ProjectileUser data)
{ {
@ -201,7 +122,7 @@ public class PerkDirtCannon extends Perk implements IThrown
} }
} }
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, 2, false, true, true, data.getThrower().getName(), GetName()); Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, 1, false, true, true, data.getThrower().getName(), GetName());
UtilAction.velocity(target, data.getThrown().getVelocity().normalize().setY(0.5).multiply(_targetKnockback)); UtilAction.velocity(target, data.getThrown().getVelocity().normalize().setY(0.5).multiply(_targetKnockback));
} }

View File

@ -0,0 +1,68 @@
package nautilus.game.arcade.game.games.skywars.kits.perks;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
public class PerkFireBurst extends SkywarsPerk
{
private static final int FIRE_TICKS = 100;
private static final double LOCATION_Y_MODIFIER = 1;
private final long _cooldown;
private final double _range, _damage;
public PerkFireBurst(ItemStack itemStack, long cooldown, double range, double damage)
{
super("Fire Burst", itemStack);
_cooldown = cooldown;
_range = range;
_damage = damage;
}
@Override
public void onUseItem(Player player)
{
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{
return;
}
Location location = player.getLocation().add(0, LOCATION_Y_MODIFIER, 0);
for (Player other : UtilPlayer.getNearby(location, _range, true))
{
if (other.equals(player))
{
continue;
}
other.setFireTicks(FIRE_TICKS);
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, true, true, player.getName(), GetName());
}
for (double radius = 0; radius < _range; radius += 0.5)
{
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 20)
{
double x = radius * Math.cos(theta);
double z = radius * Math.sin(theta);
location.add(x, 0, z);
UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.01F, 1, ViewDist.NORMAL);
location.subtract(x, 0, z);
}
}
}
}

View File

@ -0,0 +1,79 @@
package nautilus.game.arcade.game.games.skywars.kits.perks;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Effect;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.perks.data.IcePathData;
public class PerkIceBridge extends SkywarsPerk
{
private final Set<IcePathData> _data = new HashSet<>();
private final long _cooldown, _bridgeUpTime;
public PerkIceBridge(ItemStack itemStack, long cooldown, long bridgeUpTime)
{
super("Ice Bridge", itemStack);
_cooldown = cooldown;
_bridgeUpTime = bridgeUpTime;
}
@Override
public void onUseItem(Player player)
{
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{
return;
}
player.teleport(player.getLocation().add(0, 1, 0));
UtilAction.velocity(player, new Vector(0, 0.5, 0));
_data.add(new IcePathData(player));
// Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<IcePathData> dataIterator = _data.iterator();
while (dataIterator.hasNext())
{
IcePathData data = dataIterator.next();
Block block = data.GetNextBlock();
if (block == null)
{
dataIterator.remove();
}
else
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79);
Manager.GetBlockRestore().add(block, 79, (byte) 0, _bridgeUpTime);
}
}
}
}

View File

@ -1,21 +1,12 @@
package nautilus.game.arcade.kit.perks; package nautilus.game.arcade.game.games.skywars.kits.perks;
import java.util.Iterator;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -31,72 +22,30 @@ import mineplex.core.common.util.particles.effects.LineParticle;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skywars.TeamSkywars; import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.kit.Perk;
public class PerkMagnetism extends Perk public class PerkMagnetism extends SkywarsPerk
{ {
private long _cooldown; private final long _cooldown;
private int _range; private final int _range;
private double _magnituideFactor; private final double _magnituideFactor;
public PerkMagnetism(long cooldown, int range, double magnitudeFactor) public PerkMagnetism(ItemStack itemStack, long cooldown, int range, double magnitudeFactor)
{ {
super("Magnetism", new String[] {}); super("Magnetism", itemStack);
_cooldown = cooldown; _cooldown = cooldown;
_range = range; _range = range;
_magnituideFactor = magnitudeFactor; _magnituideFactor = magnitudeFactor;
} }
@EventHandler(priority = EventPriority.HIGHEST) @Override
public void onUpdate(UpdateEvent event) public void onUseItem(Player player)
{ {
if (event.getType() != UpdateType.SEC)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
if (!hasPerk(player) || UtilPlayer.isSpectator(player))
{
continue;
}
int magnitude = getAmountOfMetalArmor(player);
player.setMaxHealth(20 + magnitude);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
{
return;
}
if (player.getItemInHand().getType() != Material.REDSTONE_COMPARATOR)
{
return;
}
if (!hasPerk(player))
{
return;
}
Player target = UtilPlayer.getPlayerInSight(player, _range, true); Player target = UtilPlayer.getPlayerInSight(player, _range, true);
if (target == null) if (target == null)
@ -142,36 +91,24 @@ public class PerkMagnetism extends Perk
UtilAction.velocity(target, vector.setY(Math.max(.6, vector.getY()))); UtilAction.velocity(target, vector.setY(Math.max(.6, vector.getY())));
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerPickupItem(PlayerPickupItemEvent event) public void onUpdate(UpdateEvent event)
{ {
if (!hasPerk(event.getPlayer())) if (event.getType() != UpdateType.SEC)
{ {
return; return;
} }
ItemStack itemStack = event.getItem().getItemStack(); for (Player player : UtilServer.getPlayers())
if (UtilItem.isDiamondProduct(itemStack) && UtilItem.isArmor(itemStack))
{ {
event.setCancelled(true); if (!hasPerk(player) || UtilPlayer.isSpectator(player))
} {
continue;
} }
@EventHandler int magnitude = getAmountOfMetalArmor(player);
public void onInventoryClick(InventoryClickEvent event)
{
if (!hasPerk((Player) event.getWhoClicked()))
{
return;
}
ItemStack itemStack = event.getCurrentItem(); player.setMaxHealth(20 + magnitude);
if (UtilItem.isDiamondProduct(itemStack) && UtilItem.isArmor(itemStack))
{
event.getWhoClicked().sendMessage(F.main("Game", "You cannot equip diamond armor."));
event.setCancelled(true);
} }
} }
@ -192,57 +129,16 @@ public class PerkMagnetism extends Perk
} }
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent event) public void damage(CustomDamageEvent event)
{ {
Player player = event.getPlayer(); Player player = event.GetDamageePlayer();
ItemStack itemStack = player.getItemInHand();
if (!hasPerk(player)) if (player == null || !hasPerk(player))
{ {
return; return;
} }
if (itemStack == null) event.AddKnockback(GetName(), -0.05 * getAmountOfMetalArmor(player));
{
return;
}
if (itemStack.getType() == Material.REDSTONE_COMPARATOR)
{
event.setCancelled(true);
player.sendMessage(F.main("Game", "You cannot place this item."));
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!hasPerk(event.getPlayer()))
{
return;
}
if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_COMPARATOR)
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
Iterator<ItemStack> iterator = event.getDrops().iterator();
while (iterator.hasNext())
{
ItemStack itemStack = iterator.next();
if (itemStack.getType() == Material.REDSTONE_COMPARATOR)
{
iterator.remove();
}
}
} }
private int getAmountOfMetalArmor(Player player) private int getAmountOfMetalArmor(Player player)

View File

@ -0,0 +1,70 @@
package nautilus.game.arcade.game.games.skywars.kits.perks;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PerkVoidSaver extends SkywarsPerk
{
private final Map<Player, Location> _safeLocations = new HashMap<>();
public PerkVoidSaver(ItemStack itemStack)
{
super("Void Saver", itemStack);
}
@Override
public void onUseItem(Player player)
{
Location location = _safeLocations.get(player);
if (location == null)
{
return;
}
player.teleport(location.add(0, 2, 0));
player.setFallDistance(0);
player.getInventory().remove(Material.EYE_OF_ENDER);
player.sendMessage(F.main("Game", "You used your safe teleport."));
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 0);
UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 10, ViewDist.NORMAL);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!hasPerk(player) || !UtilEnt.isGrounded(player))
{
continue;
}
_safeLocations.put(player, player.getLocation());
}
}
}

View File

@ -0,0 +1,77 @@
package nautilus.game.arcade.game.games.skywars.kits.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import nautilus.game.arcade.kit.Perk;
public abstract class SkywarsPerk extends Perk
{
final ItemStack _itemStack;
SkywarsPerk(String name, ItemStack itemStack)
{
super(name);
_itemStack = itemStack;
}
public abstract void onUseItem(Player player);
@EventHandler(priority = EventPriority.HIGH)
public void playerInteract(PlayerInteractEvent event)
{
if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R))
{
return;
}
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (!hasPerk(player) || itemStack == null || !itemStack.isSimilar(_itemStack))
{
return;
}
onUseItem(player);
}
@EventHandler
public void blockPlace(BlockPlaceEvent event)
{
if (_itemStack.isSimilar(event.getItemInHand()))
{
event.getPlayer().sendMessage(F.main("Game", "You cannot place your " + F.name("Skill Item") + "."));
event.setCancelled(true);
}
}
@EventHandler
public void playerDropItem(PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().isSimilar(_itemStack))
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop your " + F.name("Skill Item") + "."));
event.setCancelled(true);
}
}
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
event.getDrops().removeIf(itemStack -> itemStack.isSimilar(_itemStack));
}
}

View File

@ -10,18 +10,15 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skywars.Skywars; import nautilus.game.arcade.game.games.skywars.Skywars;
import nautilus.game.arcade.game.games.skywars.kits.perks.PerkDirtCannon;
import nautilus.game.arcade.game.games.skywars.kits.perks.PerkFireBurst;
import nautilus.game.arcade.game.games.skywars.kits.perks.PerkIceBridge;
import nautilus.game.arcade.game.games.skywars.kits.perks.PerkVoidSaver;
import nautilus.game.arcade.game.games.skywars.modes.Elementalist; import nautilus.game.arcade.game.games.skywars.modes.Elementalist;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDirtCannon;
import nautilus.game.arcade.kit.perks.PerkDoubleJump; import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkFireBurst;
import nautilus.game.arcade.kit.perks.PerkIceBridge;
import nautilus.game.arcade.kit.perks.PerkKnockback;
import nautilus.game.arcade.kit.perks.PerkMagnetism;
import nautilus.game.arcade.kit.perks.PerkVoidSaver;
/** /**
* KitElementalist is a kit for the Brawl mode {@link Elementalist} which combines all {@link Skywars} kits * KitElementalist is a kit for the Brawl mode {@link Elementalist} which combines all {@link Skywars} kits
@ -39,12 +36,11 @@ public class KitElementalist extends ProgressingKit
private static final Perk[] PERKS = private static final Perk[] PERKS =
{ {
new PerkVoidSaver(), new PerkVoidSaver(null),
new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 27000, true), new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 27000, true),
new PerkDirtCannon(1.5), new PerkDirtCannon(null, 1.5),
new PerkKnockback(0.75, true), new PerkFireBurst(null,35000, 4, 6),
new PerkFireBurst(35000, 4, 6), new PerkIceBridge(null, 25000, 6000),
new PerkIceBridge(25000, 6000),
//new PerkMagnetism(15000, 10, 1.5) //new PerkMagnetism(15000, 10, 1.5)
}; };

View File

@ -7,10 +7,12 @@ import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -27,6 +29,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.modules.Module; import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.chest.ChestLootModule;
public class ZombieGuardianModule extends Module public class ZombieGuardianModule extends Module
{ {
@ -152,6 +155,29 @@ public class ZombieGuardianModule extends Module
return; return;
} }
event.SetCancelled("Zombie Blast Protection"); event.AddMod("Negate", -event.GetDamage());
event.AddMod("Blast Protection", 8);
event.SetIgnoreArmor(true);
}
@EventHandler
public void zombieDeath(EntityDeathEvent event)
{
Entity entity = event.getEntity();
if (!_zombies.containsKey(entity))
{
return;
}
ChestLootModule lootModule = getGame().getModule(ChestLootModule.class);
ItemStack randomItem = lootModule.getRandomItem("Middle");
event.getDrops().clear();
if (randomItem != null)
{
event.getDrops().add(randomItem);
}
} }
} }

View File

@ -18,6 +18,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -29,6 +30,8 @@ public class MapCrumbleModule extends Module
private final Set<Block> _worldBlocks; private final Set<Block> _worldBlocks;
private boolean _enabled; private boolean _enabled;
private long _enableAfter;
private Runnable _onCrumble;
private int _rate = 4; private int _rate = 4;
public MapCrumbleModule() public MapCrumbleModule()
@ -91,19 +94,42 @@ public class MapCrumbleModule extends Module
return _enabled; return _enabled;
} }
public MapCrumbleModule setEnableAfter(long enableAfter, Runnable onCrumble)
{
_enableAfter = enableAfter;
_onCrumble = onCrumble;
return this;
}
public MapCrumbleModule setRate(int rate) public MapCrumbleModule setRate(int rate)
{ {
_rate = rate; _rate = rate;
return this; return this;
} }
public MapCrumbleModule addWorldBlock(Block block) public long getTimeUntilCrumble()
{
return getGame().GetStateTime() + _enableAfter - System.currentTimeMillis();
}
private void addWorldBlock(Block block)
{ {
if (block.getWorld().equals(getGame().WorldData.World)) if (block.getWorld().equals(getGame().WorldData.World))
{ {
_worldBlocks.add(block); _worldBlocks.add(block);
} }
return this; }
@EventHandler
public void crumbleStart(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !getGame().IsLive() || _enabled || !UtilTime.elapsed(getGame().GetStateTime(), _enableAfter))
{
return;
}
_enabled = true;
_onCrumble.run();
} }
@EventHandler @EventHandler

View File

@ -22,6 +22,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -241,6 +242,28 @@ public class ChestLootModule extends Module
} }
} }
public ItemStack getRandomItem(String chestTypeName)
{
for (ChestType chestType1 : _chests.keySet())
{
if (!chestType1.Name.equals(chestTypeName))
{
continue;
}
ChestLootPool pool = UtilAlg.Random(chestType1.Pools);
if (pool == null)
{
return null;
}
return pool.getRandomItem();
}
return null;
}
private ChestMetadata getFromBlock(Block block) private ChestMetadata getFromBlock(Block block)
{ {
Location blockLocation = block.getLocation(); Location blockLocation = block.getLocation();

View File

@ -89,11 +89,19 @@ public class ChestLootPool
for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++) for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++)
{ {
int slot = UtilMath.r(inventory.getSize()); int slot = UtilMath.r(inventory.getSize());
inventory.setItem(slot, getRandomItem());
}
chest.update();
}
public ItemStack getRandomItem()
{
ChestLootItem item = _items.generateRandom(); ChestLootItem item = _items.generateRandom();
if (item == null) if (item == null)
{ {
continue; return null;
} }
ItemStack itemStack = item.getItem(); ItemStack itemStack = item.getItem();
@ -105,10 +113,7 @@ public class ChestLootPool
itemStack.addUnsafeEnchantment(enchantment.getKey(), UtilMath.r(enchantment.getValue()) + 1); itemStack.addUnsafeEnchantment(enchantment.getKey(), UtilMath.r(enchantment.getValue()) + 1);
} }
inventory.setItem(slot, itemStack); return itemStack;
}
chest.update();
} }
public double getProbability() public double getProbability()

View File

@ -52,7 +52,7 @@ public class Generator
_type.collect(this, player); _type.collect(this, player);
_holder.remove(); _holder.remove();
_holder = null; _holder = null;
_lastCollect = System.currentTimeMillis(); setLastCollect();
} }
public void checkSpawn() public void checkSpawn()
@ -111,4 +111,9 @@ public class Generator
{ {
return _block; return _block;
} }
public void setLastCollect()
{
_lastCollect = System.currentTimeMillis();
}
} }

View File

@ -3,13 +3,18 @@ package nautilus.game.arcade.game.modules.generator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent; import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.modules.Module; import nautilus.game.arcade.game.modules.Module;
public class GeneratorModule extends Module public class GeneratorModule extends Module
@ -64,6 +69,33 @@ public class GeneratorModule extends Module
} }
} }
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
_generators.forEach(Generator::setLastCollect);
}
@EventHandler
public void blockBreak(BlockBreakEvent event)
{
Block block = event.getBlock();
for (Generator generator : _generators)
{
if (generator.getBlock().equals(block))
{
event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Game", "You cannot break this block."));
return;
}
}
}
@EventHandler @EventHandler
public void armourStandManipulate(PlayerArmorStandManipulateEvent event) public void armourStandManipulate(PlayerArmorStandManipulateEvent event)
{ {

View File

@ -1,146 +0,0 @@
package nautilus.game.arcade.kit.perks;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.Material;
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.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
public class PerkFireBurst extends Perk
{
private static final int FIRE_TICKS = 60;
private static final double LOCATION_Y_MODIFER = 1;
private long _cooldown;
private double _range;
private double _damage;
public PerkFireBurst(long cooldown, double range, double damage)
{
super("Fire Burst", new String[] {
C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst",
"Sends out a pulse of fire that deals " + C.cGreen + damage + C.cWhite + " damage to",
"all players within " + C.cGreen + range + C.cWhite + " blocks.",
"Cooldown " + C.cGreen + UtilTime.convertString(cooldown, 0, TimeUnit.SECONDS) + C.cWhite + "." });
_cooldown = cooldown;
_range = range;
_damage = damage;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
{
return;
}
if (player.getItemInHand().getType() != Material.BLAZE_ROD)
{
return;
}
if (!hasPerk(player))
{
return;
}
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{
return;
}
final Location location = player.getLocation().add(0, LOCATION_Y_MODIFER, 0);
for (Player other : UtilPlayer.getNearby(location, _range, true))
{
if (other.equals(player))
{
continue;
}
other.setFireTicks(FIRE_TICKS);
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, true, true, player.getName(), GetName());
}
for (double radius = 0; radius < _range; radius += 0.5)
{
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 20)
{
double x = radius * Math.cos(theta);
double z = radius * Math.sin(theta);
location.add(x, 0, z);
UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.01F, 1, ViewDist.NORMAL);
location.subtract(x, 0, z);
}
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!hasPerk(event.getPlayer()))
{
return;
}
if (event.getItemDrop().getItemStack().getType() == Material.BLAZE_ROD)
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
if (!hasPerk(event.getEntity()))
{
return;
}
Iterator<ItemStack> iterator = event.getDrops().iterator();
while (iterator.hasNext())
{
ItemStack itemStack = iterator.next();
if (itemStack.getType() == Material.BLAZE_ROD)
{
iterator.remove();
}
}
}
}

View File

@ -1,184 +0,0 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
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.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.data.IcePathData;
public class PerkIceBridge extends Perk
{
private HashSet<IcePathData> _data = new HashSet<IcePathData>();
public long _cooldown;
private long _bridgeUpTime;
public PerkIceBridge(long cooldown, long bridgeUpTime)
{
super("Ice Bridge", new String[] {
C.cYellow + "Right Click" + C.cGray + " with Ice to create an " + C.cGreen + "Ice Bridge",
"Lasts for " + C.cGreen + UtilTime.convertString(bridgeUpTime, 0, TimeUnit.SECONDS) + C.cGray + ".",
"Cooldown " + C.cGreen + UtilTime.convertString(cooldown, 0, TimeUnit.SECONDS) + C.cGray + "."
});
_cooldown = cooldown;
_bridgeUpTime = bridgeUpTime;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
{
return;
}
if (player.getItemInHand().getType() != Material.ICE)
{
return;
}
if (!hasPerk(player))
{
return;
}
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{
return;
}
player.teleport(player.getLocation().add(0, 1, 0));
UtilAction.velocity(player, new Vector(0, 0.5, 0));
_data.add(new IcePathData(player));
// Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<IcePathData> dataIterator = _data.iterator();
while (dataIterator.hasNext())
{
IcePathData data = dataIterator.next();
Block block = data.GetNextBlock();
if (block == null)
{
dataIterator.remove();
}
else
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79);
Manager.GetBlockRestore().add(block, 79, (byte) 0, _bridgeUpTime);
}
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (!hasPerk(player))
{
return;
}
if (itemStack == null)
{
return;
}
if (itemStack.getItemMeta() == null)
{
return;
}
if (itemStack.getItemMeta().getDisplayName() == null)
{
return;
}
if (itemStack.getItemMeta().getDisplayName().contains(GetName()))
{
event.setCancelled(true);
player.sendMessage(F.main("Game", "You cannot place this item."));
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!hasPerk(event.getPlayer()))
{
return;
}
if (event.getItemDrop().getItemStack().getType() == Material.ICE)
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
if (!hasPerk(event.getEntity()))
{
return;
}
Iterator<ItemStack> iterator = event.getDrops().iterator();
while (iterator.hasNext())
{
ItemStack itemStack = iterator.next();
if (itemStack.getType() == Material.ICE)
{
iterator.remove();
}
}
}
}

View File

@ -5,34 +5,28 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
public class PerkKnockback extends Perk public class PerkKnockback extends Perk
{ {
private double _power;
private boolean _onGround; private final double _power;
public PerkKnockback(double power) public PerkKnockback(double power)
{
this(power, false);
}
public PerkKnockback(double power, boolean onGround)
{ {
super("Knockback", new String[] super("Knockback", new String[]
{ {
C.cGray + "Attacks gives knockback with " + C.cGreen + power + C.cGray + " power.", C.cGray + "Attacks gives knockback with " + C.cGreen + power + C.cGray + " power.",
(onGround ? "Only works while you are on the ground." : "Works in the air and on the ground."),
}); });
_power = power; _power = power;
_onGround = onGround;
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -47,11 +41,6 @@ public class PerkKnockback extends Perk
if (!Manager.IsAlive(damager)) if (!Manager.IsAlive(damager))
return; return;
if (_onGround && !UtilEnt.isGrounded(event.GetDamageeEntity()))
{
return;
}
event.SetKnockback(false); event.SetKnockback(false);
if (!Recharge.Instance.use(damager, "KB " + UtilEnt.getName(event.GetDamageeEntity()), 400, false, false)) if (!Recharge.Instance.use(damager, "KB " + UtilEnt.getName(event.GetDamageeEntity()), 400, false, false))

View File

@ -1,138 +0,0 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.kit.Perk;
public class PerkVoidSaver extends Perk
{
private Map<UUID, Location> _safeLocations = new HashMap<>();
private List<UUID> _used = new ArrayList<>();
public PerkVoidSaver()
{
super("Void Saver", new String[] {
});
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
{
return;
}
if (player.getItemInHand().getType() != Material.EYE_OF_ENDER)
{
return;
}
event.setCancelled(true);
if (!hasPerk(player) || _used.contains(player.getUniqueId()))
{
return;
}
if (_safeLocations.get(player.getUniqueId()) == null)
{
return;
}
player.teleport(_safeLocations.get(player.getUniqueId()).add(0, 2, 0));
player.setFallDistance(0);
player.getInventory().remove(Material.EYE_OF_ENDER);
player.sendMessage(F.main("Game", "You used your safe teleport."));
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 0);
UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 10, ViewDist.NORMAL);
_used.add(player.getUniqueId());
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!hasPerk(player) || _used.contains(player.getUniqueId()) || !UtilEnt.isGrounded(player))
{
continue;
}
_safeLocations.put(player.getUniqueId(), player.getLocation());
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.EYE_OF_ENDER)
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
Iterator<ItemStack> iterator = event.getDrops().iterator();
while (iterator.hasNext())
{
ItemStack itemStack = iterator.next();
if (itemStack.getType() == Material.EYE_OF_ENDER)
{
iterator.remove();
}
}
}
@EventHandler
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == GameState.WinRoom)
{
_used.clear();
}
}
}