Cake Wars 1.4

This commit is contained in:
Sam 2018-02-27 16:33:27 +00:00 committed by Alexander Meech
parent 888861c4e5
commit 60a468d03d
14 changed files with 380 additions and 147 deletions

View File

@ -10,6 +10,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.server.v1_8_R3.AxisAlignedBB; import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.EntityArrow;
import net.minecraft.server.v1_8_R3.EntityBat; import net.minecraft.server.v1_8_R3.EntityBat;
import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.EntityEnderDragon; import net.minecraft.server.v1_8_R3.EntityEnderDragon;
@ -37,10 +38,12 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.TrigMath; import org.bukkit.craftbukkit.v1_8_R3.TrigMath;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -1089,4 +1092,36 @@ public class UtilEnt
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
((CraftWorld) location.getWorld()).getHandle().addEntity(entity, SpawnReason.CUSTOM); ((CraftWorld) location.getWorld()).getHandle().addEntity(entity, SpawnReason.CUSTOM);
} }
public static Block getHitBlock(Entity arrow)
{
if (!(arrow instanceof Arrow))
{
return null;
}
try
{
EntityArrow entityArrow = ((CraftArrow) arrow).getHandle();
Field fieldX = EntityArrow.class.getDeclaredField("d");
Field fieldY = EntityArrow.class.getDeclaredField("e");
Field fieldZ = EntityArrow.class.getDeclaredField("f");
fieldX.setAccessible(true);
fieldY.setAccessible(true);
fieldZ.setAccessible(true);
int x = fieldX.getInt(entityArrow);
int y = fieldY.getInt(entityArrow);
int z = fieldZ.getInt(entityArrow);
return arrow.getWorld().getBlockAt(x, y, z);
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
}
} }

View File

@ -495,7 +495,8 @@ public enum GameKit
{ {
"Get extra blocks to build with!", "Get extra blocks to build with!",
C.blankLine, C.blankLine,
receiveItem("Wool Block", 1, 4, 32), receiveItem("Knitted Wool", 1, 4, 32),
receiveItem("Knitted Platform", 1, 10, 5),
}, },
new KitEntityData<> new KitEntityData<>
( (

View File

@ -13,11 +13,17 @@ import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
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.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
@ -104,6 +110,7 @@ public class CakeWars extends TeamGame
private static final LeaderboardManager LEADERBOARD_MANAGER = Managers.get(LeaderboardManager.class); private static final LeaderboardManager LEADERBOARD_MANAGER = Managers.get(LeaderboardManager.class);
private final Map<GameTeam, Location> _averages; private final Map<GameTeam, Location> _averages;
private final Cache<Long, Player> _deathsInLastMinute;
private final CakeTeamModule _cakeTeamModule; private final CakeTeamModule _cakeTeamModule;
private final CakePlayerModule _cakePlayerModule; private final CakePlayerModule _cakePlayerModule;
@ -134,6 +141,9 @@ public class CakeWars extends TeamGame
}, DESCRIPTION); }, DESCRIPTION);
_averages = new HashMap<>(4); _averages = new HashMap<>(4);
_deathsInLastMinute = CacheBuilder.newBuilder()
.expireAfterWrite(60, TimeUnit.SECONDS)
.build();
AnnounceStay = false; AnnounceStay = false;
BlockPlace = true; BlockPlace = true;
@ -573,7 +583,37 @@ public class CakeWars extends TeamGame
@Override @Override
public double GetKillsGems(Player killer, Player killed, boolean assist) public double GetKillsGems(Player killer, Player killed, boolean assist)
{ {
return assist ? 2 : 6; if (getDeathsInLastMinute(killed) > 2)
{
return 0;
}
return assist ? 1 : 3;
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerDeath(PlayerDeathEvent event)
{
if (!IsLive())
{
return;
}
Player player = event.getEntity();
_deathsInLastMinute.put(System.currentTimeMillis(), player);
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_deathsInLastMinute.asMap().values().removeIf(player -> player.equals(event.getPlayer()));
}
public int getDeathsInLastMinute(Player player)
{
return (int) _deathsInLastMinute.asMap().values().stream()
.filter(player::equals)
.count();
} }
public Location getAverageLocation(GameTeam team) public Location getAverageLocation(GameTeam team)

View File

@ -1,7 +1,9 @@
package nautilus.game.arcade.game.games.cakewars.general; package nautilus.game.arcade.game.games.cakewars.general;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -28,14 +30,19 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C; 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.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
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 mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -44,6 +51,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule; import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
@ -66,7 +74,7 @@ public class CakePlayerModule extends CakeModule
.setUnbreakable(true) .setUnbreakable(true)
.build(); .build();
private static final int PLATFORM_DELTA = 1; private static final int PLATFORM_DELTA = 1;
private static final PotionEffect SPAWN_PROTECTION = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 120, 0); private static final int PLATFORM_WARMUP_TICKS = 40;
private final Set<Block> _placedBlocks; private final Set<Block> _placedBlocks;
// Used to store the inventory of a player when using the rune of holding // Used to store the inventory of a player when using the rune of holding
@ -128,7 +136,7 @@ public class CakePlayerModule extends CakeModule
{ {
event.setCancelled(true); event.setCancelled(true);
} }
else if (UtilBlock.airFoliage(event.getBlock())) else if (UtilBlock.airFoliage(block) || block.getType() == Material.LEAVES || block.getType() == Material.LEAVES_2)
{ {
event.setCancelled(true); event.setCancelled(true);
block.setType(Material.AIR); block.setType(Material.AIR);
@ -136,7 +144,7 @@ public class CakePlayerModule extends CakeModule
else if (!_placedBlocks.contains(block)) else if (!_placedBlocks.contains(block))
{ {
event.setCancelled(true); event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Game", "You cannot break blocks that have not been placed by players.")); player.sendMessage(F.main("Game", "You cannot break blocks that have not been placed by players."));
} }
} }
@ -278,7 +286,7 @@ public class CakePlayerModule extends CakeModule
{ {
Player player = event.GetPlayer(); Player player = event.GetPlayer();
_game.getArcadeManager().runSyncLater(() -> player.addPotionEffect(SPAWN_PROTECTION), 5); _game.getArcadeManager().runSyncLater(() -> player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (6 + _game.getDeathsInLastMinute(player) * 2) * 20, 0)), 5);
} }
@EventHandler @EventHandler
@ -328,7 +336,8 @@ public class CakePlayerModule extends CakeModule
} }
BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace(); BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace();
byte teamData = _game.GetTeam(player).GetColorData(); GameTeam team = _game.GetTeam(player);
byte teamData = team.GetColorData();
boolean blockChanged = false; boolean blockChanged = false;
if (itemStack.getType() == DEPLOY_PLATFORM.getType()) if (itemStack.getType() == DEPLOY_PLATFORM.getType())
@ -357,6 +366,12 @@ public class CakePlayerModule extends CakeModule
{ {
event.setCancelled(true); event.setCancelled(true);
if (!Recharge.Instance.use(player, "Place Wall", 500, false, false))
{
return;
}
List<Block> changed = new ArrayList<>();
boolean xAxis = face == BlockFace.NORTH || face == BlockFace.SOUTH; boolean xAxis = face == BlockFace.NORTH || face == BlockFace.SOUTH;
block = block.getRelative(BlockFace.UP).getRelative(BlockFace.UP); block = block.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
@ -365,7 +380,6 @@ public class CakePlayerModule extends CakeModule
for (int y = -PLATFORM_DELTA; y <= PLATFORM_DELTA; y++) for (int y = -PLATFORM_DELTA; y <= PLATFORM_DELTA; y++)
{ {
Block nearby = block.getRelative(xAxis ? x : 0, y, xAxis ? 0 : x); Block nearby = block.getRelative(xAxis ? x : 0, y, xAxis ? 0 : x);
Location nearbyLocation = nearby.getLocation();
if (isInvalidBlock(nearby)) if (isInvalidBlock(nearby))
{ {
@ -373,15 +387,53 @@ public class CakePlayerModule extends CakeModule
} }
_placedBlocks.add(nearby); _placedBlocks.add(nearby);
MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData); changed.add(nearby);
blockChanged = true; blockChanged = true;
if (Math.random() > 0.5)
{
nearbyLocation.getWorld().playEffect(nearbyLocation, Effect.STEP_SOUND, Material.WOOL, teamData);
}
} }
} }
DustSpellColor color = new DustSpellColor(team.GetColorBase());
_game.getArcadeManager().runSyncTimer(new BukkitRunnable()
{
int ticks = 0;
@Override
public void run()
{
if (++ticks == PLATFORM_WARMUP_TICKS)
{
cancel();
for (Block wall : changed)
{
MapUtil.QuickChangeBlockAt(wall.getLocation(), Material.WOOL, teamData);
if (Math.random() > 0.5)
{
wall.getWorld().playEffect(wall.getLocation(), Effect.STEP_SOUND, Material.WOOL, teamData);
}
}
}
else
{
int index = 0;
double maxY = ((double) ticks / PLATFORM_WARMUP_TICKS) * 3;
for (Block wall : changed)
{
if (index++ % 3 == 0)
{
for (double y = 0; y < maxY; y += 0.2)
{
new ColoredParticle(ParticleType.RED_DUST, color, wall.getLocation().add(xAxis ? Math.random() : 0.5, y, xAxis ? 0.5 : Math.random()))
.display();
}
}
}
}
}
}, 0, 1);
} }
if (blockChanged) if (blockChanged)

View File

@ -1,7 +1,17 @@
package nautilus.game.arcade.game.games.cakewars.kits; package nautilus.game.arcade.game.games.cakewars.kits;
import org.bukkit.entity.Player; import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.game.kit.GameKit; import mineplex.core.game.kit.GameKit;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
@ -14,12 +24,16 @@ public class KitCakeArcher extends Kit
private static final Perk[] PERKS = private static final Perk[] PERKS =
{ {
new PerkFletcher(6, 3, true) new PerkFletcher(6, 3, true, -1, true, "Piercing Arrows"),
}; };
private final Set<Entity> _piercingArrows;
public KitCakeArcher(ArcadeManager manager) public KitCakeArcher(ArcadeManager manager)
{ {
super(manager, GameKit.CAKE_WARS_ARCHER, PERKS); super(manager, GameKit.CAKE_WARS_ARCHER, PERKS);
_piercingArrows = new HashSet<>();
} }
@Override @Override
@ -27,4 +41,42 @@ public class KitCakeArcher extends Kit
{ {
} }
@EventHandler
public void bowShoot(EntityShootBowEvent event)
{
if (!(event.getEntity() instanceof Player))
{
return;
}
Player player = (Player) event.getEntity();
if (!HasKit(player) || event.getForce() != 1)
{
return;
}
_piercingArrows.add(event.getProjectile());
}
@EventHandler
public void projectileHit(ProjectileHitEvent event)
{
if (!_piercingArrows.remove(event.getEntity()))
{
return;
}
Manager.runSyncLater(() ->
{
Block block = UtilEnt.getHitBlock(event.getEntity());
if (block.getType() != Material.WOOL)
{
return;
}
block.breakNaturally();
}, 0);
}
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
public class PerkLifeSteal extends Perk public class PerkLifeSteal extends Perk
@ -23,11 +24,15 @@ public class PerkLifeSteal extends Perk
@EventHandler @EventHandler
public void playerDeath(PlayerDeathEvent event) public void playerDeath(PlayerDeathEvent event)
{ {
Player killer = event.getEntity().getKiller(); Player player = event.getEntity();
Player killer = player.getKiller();
if (killer != null && hasPerk(killer)) if (killer != null && hasPerk(killer))
{ {
UtilPlayer.health(killer, _increase); CakeWars game = (CakeWars) Manager.GetGame();
double increase = Math.max(0, _increase - game.getDeathsInLastMinute(player));
UtilPlayer.health(killer, increase);
} }
} }
} }

View File

@ -5,23 +5,35 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
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.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
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.GameTeam;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule; import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
public class PerkPassiveWoolGain extends Perk public class PerkPassiveWoolGain extends Perk
{ {
private static final long WOOL_RECHARGE = TimeUnit.SECONDS.toMillis(4);
private static final long PLATFORM_RECHARGE = TimeUnit.SECONDS.toMillis(10); private static final long PLATFORM_RECHARGE = TimeUnit.SECONDS.toMillis(10);
private static final int MAX_WOOL = 32; private static final int MAX_WOOL = 32;
private static final int MAX_PLATFORMS = 8; private static final int MAX_PLATFORMS = 5;
private static final String WOOL_NAME = "Knitted Wool";
private static final String PLATFORM_NAME = "Knitted Platform";
private static final ItemStack PLATFORM_ITEM = new ItemBuilder(CakePlayerModule.DEPLOY_PLATFORM)
.setTitle(C.cYellowB + PLATFORM_NAME)
.build();
public PerkPassiveWoolGain() public PerkPassiveWoolGain()
{ {
@ -31,7 +43,7 @@ public class PerkPassiveWoolGain extends Perk
@EventHandler @EventHandler
public void updateGain(UpdateEvent event) public void updateGain(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC_05 || !Manager.GetGame().IsLive()) if (event.getType() != UpdateType.SEC || !Manager.GetGame().IsLive())
{ {
return; return;
} }
@ -43,16 +55,16 @@ public class PerkPassiveWoolGain extends Perk
continue; continue;
} }
if (!player.getInventory().contains(Material.WOOL, MAX_WOOL)) if (!player.getInventory().contains(Material.WOOL, MAX_WOOL) && Recharge.Instance.use(player, WOOL_NAME, WOOL_RECHARGE, false, false))
{ {
ItemStack itemStack = new ItemStack(Material.WOOL, 1, (short) 0, Manager.GetGame().GetTeam(player).GetColorData()); ItemStack itemStack = new ItemStack(Material.WOOL, 1, (short) 0, Manager.GetGame().GetTeam(player).GetColorData());
player.getInventory().addItem(itemStack); player.getInventory().addItem(itemStack);
} }
if (!player.getInventory().contains(Material.INK_SACK, MAX_PLATFORMS) && Recharge.Instance.use(player, "Knitted Platforms", PLATFORM_RECHARGE, false, false)) if (!player.getInventory().contains(Material.INK_SACK, MAX_PLATFORMS) && Recharge.Instance.use(player, PLATFORM_NAME, PLATFORM_RECHARGE, false, false))
{ {
ItemStack itemStack = new ItemBuilder(CakePlayerModule.DEPLOY_PLATFORM) ItemStack itemStack = new ItemBuilder(PLATFORM_ITEM)
.setData(Manager.GetGame().GetTeam(player).getDyeColor().getDyeData()) .setData(Manager.GetGame().GetTeam(player).getDyeColor().getDyeData())
.build(); .build();
@ -60,4 +72,32 @@ public class PerkPassiveWoolGain extends Perk
} }
} }
} }
@EventHandler
public void inventoryClick(InventoryClickEvent event)
{
Player player = (Player) event.getWhoClicked();
GameTeam team = Manager.GetGame().GetTeam(player);
if (!hasPerk(player) || team == null)
{
return;
}
UtilInv.DisallowMovementOf(event, PLATFORM_NAME, PLATFORM_ITEM.getType(), team.getDyeColor().getDyeData(), true);
}
@EventHandler
public void playerDrop(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
ItemStack itemStack = event.getItemDrop().getItemStack();
GameTeam team = Manager.GetGame().GetTeam(player);
if (hasPerk(player) && team != null && UtilInv.IsItem(itemStack, PLATFORM_NAME, PLATFORM_ITEM.getType(), team.getDyeColor().getDyeData()))
{
event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Game", "You cannot drop " + F.item(PLATFORM_NAME) + "."));
}
}
} }

View File

@ -10,8 +10,8 @@ import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -29,7 +29,11 @@ import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
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.UtilPlayer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.newnpc.NPC; import mineplex.core.newnpc.NPC;
import mineplex.core.newnpc.NewNPCManager; import mineplex.core.newnpc.NewNPCManager;
@ -58,6 +62,7 @@ public class CakeShopModule extends CakeModule
.setTitle(C.cPurpleB + "Ender Pearl") .setTitle(C.cPurpleB + "Ender Pearl")
.addLore("", "Warning! Ender Pearls have a", C.cRed + "7 second" + C.cGray + " cooldown between uses.") .addLore("", "Warning! Ender Pearls have a", C.cRed + "7 second" + C.cGray + " cooldown between uses.")
.build(); .build();
static final int HEALING_STATION_RADIUS = 5;
private final NewNPCManager _manager; private final NewNPCManager _manager;
private final Map<NPC, CakeResource> _npcs; private final Map<NPC, CakeResource> _npcs;
@ -81,8 +86,8 @@ public class CakeShopModule extends CakeModule
// Iron Set // Iron Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.IRON_HELMET), 5), new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.IRON_HELMET), 5),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.IRON_CHESTPLATE), 7), new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.IRON_CHESTPLATE), 8),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.IRON_LEGGINGS), 7), new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.IRON_LEGGINGS), 6),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.IRON_BOOTS), 5), new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.IRON_BOOTS), 5),
// Sword // Sword
@ -98,7 +103,7 @@ public class CakeShopModule extends CakeModule
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.IRON_AXE), 3), new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.IRON_AXE), 3),
// Arrow // Arrow
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 15), new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 12),
// Blocks // Blocks
// Wool // Wool
@ -125,8 +130,8 @@ public class CakeShopModule extends CakeModule
// Diamond Set // Diamond Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.DIAMOND_HELMET), 10), new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.DIAMOND_HELMET), 10),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 20), new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 24),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 20), new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 16),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.DIAMOND_BOOTS), 10), new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.DIAMOND_BOOTS), 10),
// Sword // Sword
@ -154,7 +159,7 @@ public class CakeShopModule extends CakeModule
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20), new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
// Insta-Wall // Insta-Wall
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.INSTA_WALL, 3), new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.INSTA_WALL, 2),
// Traps // Traps
new CakeTNTTrap(8), new CakeTNTTrap(8),
@ -307,6 +312,38 @@ public class CakeShopModule extends CakeModule
}); });
} }
@EventHandler
public void updateHealingParticles(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST || !_game.IsLive())
{
return;
}
_game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) ->
{
if (cakeTeam.getUpgrades().getOrDefault(CakeTeamItem.REGENERATION, 0) == 0)
{
return;
}
Location location = cakeTeam.getCake().clone();
DustSpellColor color = new DustSpellColor(team.GetColorBase());
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 20)
{
double x = HEALING_STATION_RADIUS * Math.cos(theta), z = HEALING_STATION_RADIUS * Math.sin(theta);
location.add(x, 0, z);
new ColoredParticle(ParticleType.RED_DUST, color, location)
.display();
location.subtract(x, 0, z);
}
});
}
@EventHandler @EventHandler
public void playerDeath(PlayerDeathEvent event) public void playerDeath(PlayerDeathEvent event)
{ {

View File

@ -72,7 +72,7 @@ public enum CakeTeamItem implements CakeItem
"Resource Generator", "Resource Generator",
new ItemStack(Material.NETHER_STAR), new ItemStack(Material.NETHER_STAR),
10, 10,
18 20
), ),
REGENERATION( REGENERATION(
"Healing Station", "Healing Station",
@ -83,7 +83,7 @@ public enum CakeTeamItem implements CakeItem
@Override @Override
public void apply(Player player, int level, Location cake) public void apply(Player player, int level, Location cake)
{ {
if (UtilMath.offset2dSquared(player.getLocation(), cake) < 25) if (UtilMath.offset2dSquared(player.getLocation(), cake) < CakeShopModule.HEALING_STATION_RADIUS * CakeShopModule.HEALING_STATION_RADIUS)
{ {
player.removePotionEffect(PotionEffectType.REGENERATION); player.removePotionEffect(PotionEffectType.REGENERATION);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, level - 1, true, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, level - 1, true, false));

View File

@ -53,7 +53,7 @@ public class CakeTeam
_chest = chest.getBlock().getLocation(); _chest = chest.getBlock().getLocation();
_generator = generator.add(0, 1, 0); _generator = generator.add(0, 1, 0);
_cake = game.WorldData.GetDataLocs(team.GetName().toUpperCase()).get(0).getBlock().getLocation(); _cake = game.WorldData.GetDataLocs(team.GetName().toUpperCase()).get(0).getBlock().getLocation().add(0.5, 0.5, 0.5);
_cake.getBlock().setType(Material.CAKE_BLOCK); _cake.getBlock().setType(Material.CAKE_BLOCK);
_upgrades = new HashMap<>(CakeTeamItem.values().length); _upgrades = new HashMap<>(CakeTeamItem.values().length);

View File

@ -208,7 +208,7 @@ public class CakeTeamModule extends CakeModule
_teams.forEach((team, cakeTeam) -> _teams.forEach((team, cakeTeam) ->
{ {
if (!block.getLocation().equals(cakeTeam.getCake())) if (!block.equals(cakeTeam.getCake().getBlock()))
{ {
return; return;
} }
@ -393,6 +393,7 @@ public class CakeTeamModule extends CakeModule
if (killer != null) if (killer != null)
{ {
_game.AddGems(killer, 2, "Final Kills", true, true);
_game.AddStat(killer, "FinalKills", 1, false, false); _game.AddStat(killer, "FinalKills", 1, false, false);
} }

View File

@ -225,7 +225,7 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
ItemBuilder give = new ItemBuilder(_item.getItemStack()); ItemBuilder give = new ItemBuilder(_item.getItemStack());
Material material = give.getType(); Material material = give.getType();
if (UtilItem.isWeapon(material) || UtilItem.isTool(material) || UtilItem.isArmor(material) || material == Material.SHEARS) if (UtilItem.isWeapon(material) || UtilItem.isTool(material) || UtilItem.isArmor(material) || material == Material.BOW || material == Material.SHEARS)
{ {
give.setUnbreakable(true); give.setUnbreakable(true);
} }

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.game.games.turfforts; package nautilus.game.arcade.game.games.turfforts;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -15,7 +14,6 @@ import org.bukkit.Material;
import org.bukkit.Sound; 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.craftbukkit.v1_8_R3.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -40,6 +38,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
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.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -50,6 +49,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
@ -67,7 +67,6 @@ import nautilus.game.arcade.stats.BlockBreakStatTracker;
import nautilus.game.arcade.stats.BlockPlaceStatTracker; import nautilus.game.arcade.stats.BlockPlaceStatTracker;
import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.BlockShreadStatTracker;
import nautilus.game.arcade.stats.TheComebackStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker;
import net.minecraft.server.v1_8_R3.EntityArrow;
public class TurfForts extends TeamGame public class TurfForts extends TeamGame
{ {
@ -119,11 +118,11 @@ public class TurfForts extends TeamGame
private int _lines = 0; private int _lines = 0;
private BlockBreakStatTracker _breakStatTracker; private BlockBreakStatTracker _breakStatTracker;
private HashMap<Player, Long> _enemyTurf = new HashMap<Player, Long>(); private HashMap<Player, Long> _enemyTurf = new HashMap<Player, Long>();
private Set<UUID> playersThatNeedBlocks = new HashSet<UUID>(); private Set<UUID> playersThatNeedBlocks = new HashSet<UUID>();
public TurfForts(ArcadeManager manager) public TurfForts(ArcadeManager manager)
{ {
super(manager, GameType.TurfWars, super(manager, GameType.TurfWars,
@ -159,7 +158,7 @@ public class TurfForts extends TeamGame
new BlockShreadStatTracker(this), new BlockShreadStatTracker(this),
new BehindEnemyLinesStatTracker(this), new BehindEnemyLinesStatTracker(this),
new TheComebackStatTracker(this), new TheComebackStatTracker(this),
new BlockPlaceStatTracker(this, new Material[]{}), new BlockPlaceStatTracker(this, new Material[] {}),
_breakStatTracker _breakStatTracker
); );
@ -305,7 +304,7 @@ public class TurfForts extends TeamGame
EndCheck(); EndCheck();
} }
} }
@EventHandler @EventHandler
public void BowCancel(EntityShootBowEvent event) public void BowCancel(EntityShootBowEvent event)
{ {
@ -313,7 +312,7 @@ public class TurfForts extends TeamGame
{ {
UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!")); UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!"));
event.setCancelled(true); event.setCancelled(true);
((Player) event.getEntity()).updateInventory(); ((Player) event.getEntity()).updateInventory();
} }
} }
@ -323,9 +322,8 @@ public class TurfForts extends TeamGame
{ {
if (event.isCancelled()) // this statement might save just a small amount of time if (event.isCancelled()) // this statement might save just a small amount of time
return; return;
if (!IsAlive(event.getPlayer())) if (!IsAlive(event.getPlayer()))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -337,9 +335,9 @@ public class TurfForts extends TeamGame
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
Block block = event.getBlock(); Block block = event.getBlock();
GameTeam team = GetTeam(event.getPlayer()); GameTeam team = GetTeam(event.getPlayer());
GameTeam otherTeam = GetOtherTeam(team); GameTeam otherTeam = GetOtherTeam(team);
@ -376,7 +374,7 @@ public class TurfForts extends TeamGame
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
//On Own //On Own
Block block = event.getBlock().getRelative(BlockFace.DOWN); Block block = event.getBlock().getRelative(BlockFace.DOWN);
while (block.getTypeId() == 0 && block.getY() > 0) while (block.getTypeId() == 0 && block.getY() > 0)
@ -427,54 +425,30 @@ public class TurfForts extends TeamGame
final Arrow arrow = (Arrow) event.getEntity(); final Arrow arrow = (Arrow) event.getEntity();
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() Manager.runSyncLater(() ->
{ {
public void run() Block block = UtilEnt.getHitBlock(arrow);
if (block.getTypeId() == 35)
{ {
try if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */)
{ {
EntityArrow entityArrow = ((CraftArrow) arrow).getHandle(); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId());
_breakStatTracker.addStat(shooter);
Field fieldX = EntityArrow.class.getDeclaredField("d");
Field fieldY = EntityArrow.class.getDeclaredField("e");
Field fieldZ = EntityArrow.class.getDeclaredField("f");
fieldX.setAccessible(true);
fieldY.setAccessible(true);
fieldZ.setAccessible(true);
int x = fieldX.getInt(entityArrow);
int y = fieldY.getInt(entityArrow);
int z = fieldZ.getInt(entityArrow);
Block block = arrow.getWorld().getBlockAt(x, y, z);
if (block.getTypeId() == 35)
{
if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId());
_breakStatTracker.addStat(shooter);
}
else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
_breakStatTracker.addStat(shooter);
}
Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow));
block.setType(Material.AIR);
}
arrow.remove();
} }
catch (Exception e) else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */)
{ {
e.printStackTrace(); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
_breakStatTracker.addStat(shooter);
} }
Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow));
block.setType(Material.AIR);
} }
arrow.remove();
}, 0); }, 0);
} }
@ -593,18 +567,18 @@ public class TurfForts extends TeamGame
} }
} }
} }
public void addBlocks(GameTeam team, Player player) public void addBlocks(GameTeam team, Player player)
{ {
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24));
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onQuit(PlayerQuitEvent event) public void onQuit(PlayerQuitEvent event)
{ {
this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId()); this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onSpawn(PlayerKitGiveEvent event) public void onSpawn(PlayerKitGiveEvent event)
{ {
@ -615,9 +589,8 @@ public class TurfForts extends TeamGame
this.addBlocks(GetTeam(player), player); this.addBlocks(GetTeam(player), player);
} }
} }
@Override @Override
@EventHandler @EventHandler
public void ScoreboardUpdate(UpdateEvent event) public void ScoreboardUpdate(UpdateEvent event)
@ -718,8 +691,8 @@ public class TurfForts extends TeamGame
{ {
for (Player player : team.GetPlayers(true)) for (Player player : team.GetPlayers(true))
{ {
if (((CraftPlayer) player).getHandle().spectating) if (((CraftPlayer) player).getHandle().spectating)
continue; continue;
//Slow //Slow
if (_enemyTurf.containsKey(player)) if (_enemyTurf.containsKey(player))
@ -731,20 +704,20 @@ public class TurfForts extends TeamGame
} }
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
// Apply velocity even if the player is sneaking near turf edges. // Apply velocity even if the player is sneaking near turf edges.
if (block.isEmpty() && player.isOnGround()) if (block.isEmpty() && player.isOnGround())
{ {
Block[] nearby = { Block[] nearby = {
block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.NORTH),
block.getRelative(BlockFace.SOUTH), block.getRelative(BlockFace.SOUTH),
block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.WEST),
block.getRelative(BlockFace.EAST), block.getRelative(BlockFace.EAST),
block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.NORTH_EAST),
block.getRelative(BlockFace.NORTH_WEST), block.getRelative(BlockFace.NORTH_WEST),
block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_EAST),
block.getRelative(BlockFace.SOUTH_WEST) block.getRelative(BlockFace.SOUTH_WEST)
}; };
for (Block near : nearby) for (Block near : nearby)
@ -756,7 +729,7 @@ public class TurfForts extends TeamGame
} }
} }
} }
while (block.getTypeId() != 159 && block.getY() > 0) while (block.getTypeId() != 159 && block.getY() > 0)
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
@ -786,7 +759,7 @@ public class TurfForts extends TeamGame
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!")); UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!"));
} }
// return; // return;
} }
//On Own Turf //On Own Turf
@ -818,19 +791,22 @@ public class TurfForts extends TeamGame
} }
} }
*/ */
public GameTeam GetOtherTeam(GameTeam team) { public GameTeam GetOtherTeam(GameTeam team)
{
return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED);
} }
@EventHandler @EventHandler
public void onItem(ItemSpawnEvent e) { public void onItem(ItemSpawnEvent e)
if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { {
if (e.getEntityType().equals(EntityType.DROPPED_ITEM))
{
e.setCancelled(true); e.setCancelled(true);
} }
} }
@Override @Override
public void EndCheck() public void EndCheck()
{ {
@ -860,31 +836,31 @@ public class TurfForts extends TeamGame
if (player.isOnline()) if (player.isOnline())
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
endElo(); endElo();
//End //End
SetState(GameState.End); SetState(GameState.End);
} }
public Long getEnemyTurfEntranceTime(Player player) public Long getEnemyTurfEntranceTime(Player player)
{ {
return _enemyTurf.get(player); return _enemyTurf.get(player);
} }
// Fixed by TeddyDev. // Fixed by TeddyDev.
@EventHandler @EventHandler
public void blockGlitchFix(PlayerInteractEvent event) public void blockGlitchFix(PlayerInteractEvent event)
{ {
if(event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return; return;
if(event.getPlayer().isOnGround()) if (event.getPlayer().isOnGround())
return; return;
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if(block.getType() == Material.STAINED_CLAY || block.getType() == Material.WOOL) if (block.getType() == Material.STAINED_CLAY || block.getType() == Material.WOOL)
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -894,7 +870,7 @@ public class TurfForts extends TeamGame
ground = ground.getRelative(BlockFace.DOWN); ground = ground.getRelative(BlockFace.DOWN);
} }
if(ground.isLiquid()) if (ground.isLiquid())
{ {
Manager.GetDamage().NewDamageEvent(player, null, null, Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.VOID, 9001, false, false, false, DamageCause.VOID, 9001, false, false, false,
@ -903,7 +879,7 @@ public class TurfForts extends TeamGame
return; return;
} }
if(player.getLocation().distance(ground.getLocation()) < 4) if (player.getLocation().distance(ground.getLocation()) < 4)
return; return;
Manager.GetDamage().NewDamageEvent(player, null, null, Manager.GetDamage().NewDamageEvent(player, null, null,
@ -911,16 +887,16 @@ public class TurfForts extends TeamGame
"Border", "Border Damage"); "Border", "Border Damage");
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
} }
// Keep ladders placed on ice when block updates occur. // Keep ladders placed on ice when block updates occur.
@EventHandler @EventHandler
public void ladderDestroyFix(BlockPhysicsEvent event) public void ladderDestroyFix(BlockPhysicsEvent event)
{ {
if (!IsLive()) if (!IsLive())
return; return;
Block block = event.getBlock(); Block block = event.getBlock();
if (block.getType() == Material.LADDER) if (block.getType() == Material.LADDER)
{ {
event.setCancelled(true); event.setCancelled(true);

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -32,7 +33,8 @@ import org.bukkit.inventory.meta.ItemMeta;
public class PerkFletcher extends Perk public class PerkFletcher extends Perk
{ {
private HashSet<Entity> _fletchArrows = new HashSet<Entity>();
private final Set<Entity> _fletchArrows = new HashSet<>();
private int _max = 0; private int _max = 0;
private int _time = 0; private int _time = 0;
@ -94,17 +96,13 @@ public class PerkFletcher extends Perk
public boolean isFletchedArrow(ItemStack stack) public boolean isFletchedArrow(ItemStack stack)
{ {
if (!UtilGear.isMat(stack, Material.ARROW)) if (!UtilGear.isMat(stack, Material.ARROW))
{
return false; return false;
}
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
if (meta.getDisplayName() == null) return meta.hasDisplayName() && meta.getDisplayName().contains(_name);
return false;
if (!meta.getDisplayName().contains(_name))
return false;
return true;
} }
@EventHandler @EventHandler
@ -245,14 +243,10 @@ public class PerkFletcher extends Perk
public void FletchClean(UpdateEvent event) public void FletchClean(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return;
for (Iterator<Entity> arrowIterator = _fletchArrows.iterator(); arrowIterator.hasNext();)
{ {
Entity arrow = arrowIterator.next(); return;
if (arrow.isDead() || !arrow.isValid())
arrowIterator.remove();
} }
_fletchArrows.removeIf(arrow -> arrow.isDead() || !arrow.isValid());
} }
} }