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 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.EntityCreature;
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
@ -37,10 +38,12 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -1089,4 +1092,36 @@ public class UtilEnt
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
((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!",
C.blankLine,
receiveItem("Wool Block", 1, 4, 32),
receiveItem("Knitted Wool", 1, 4, 32),
receiveItem("Knitted Platform", 1, 10, 5),
},
new KitEntityData<>
(

View File

@ -13,11 +13,17 @@ import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
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.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import mineplex.core.Managers;
import mineplex.core.common.util.C;
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 final Map<GameTeam, Location> _averages;
private final Cache<Long, Player> _deathsInLastMinute;
private final CakeTeamModule _cakeTeamModule;
private final CakePlayerModule _cakePlayerModule;
@ -134,6 +141,9 @@ public class CakeWars extends TeamGame
}, DESCRIPTION);
_averages = new HashMap<>(4);
_deathsInLastMinute = CacheBuilder.newBuilder()
.expireAfterWrite(60, TimeUnit.SECONDS)
.build();
AnnounceStay = false;
BlockPlace = true;
@ -573,7 +583,37 @@ public class CakeWars extends TeamGame
@Override
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)

View File

@ -1,7 +1,9 @@
package nautilus.game.arcade.game.games.cakewars.general;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -28,14 +30,19 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle.ParticleType;
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.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
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.PlayerKitGiveEvent;
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.CakeWars;
@ -66,7 +74,7 @@ public class CakePlayerModule extends CakeModule
.setUnbreakable(true)
.build();
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;
// 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);
}
else if (UtilBlock.airFoliage(event.getBlock()))
else if (UtilBlock.airFoliage(block) || block.getType() == Material.LEAVES || block.getType() == Material.LEAVES_2)
{
event.setCancelled(true);
block.setType(Material.AIR);
@ -136,7 +144,7 @@ public class CakePlayerModule extends CakeModule
else if (!_placedBlocks.contains(block))
{
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();
_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
@ -328,7 +336,8 @@ public class CakePlayerModule extends CakeModule
}
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;
if (itemStack.getType() == DEPLOY_PLATFORM.getType())
@ -357,6 +366,12 @@ public class CakePlayerModule extends CakeModule
{
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;
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++)
{
Block nearby = block.getRelative(xAxis ? x : 0, y, xAxis ? 0 : x);
Location nearbyLocation = nearby.getLocation();
if (isInvalidBlock(nearby))
{
@ -373,15 +387,53 @@ public class CakePlayerModule extends CakeModule
}
_placedBlocks.add(nearby);
MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData);
changed.add(nearby);
blockChanged = true;
}
}
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)
{
nearbyLocation.getWorld().playEffect(nearbyLocation, Effect.STEP_SOUND, Material.WOOL, teamData);
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)

View File

@ -1,7 +1,17 @@
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 nautilus.game.arcade.ArcadeManager;
@ -14,12 +24,16 @@ public class KitCakeArcher extends Kit
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)
{
super(manager, GameKit.CAKE_WARS_ARCHER, PERKS);
_piercingArrows = new HashSet<>();
}
@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 nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.kit.Perk;
public class PerkLifeSteal extends Perk
@ -23,11 +24,15 @@ public class PerkLifeSteal extends Perk
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
Player killer = event.getEntity().getKiller();
Player player = event.getEntity();
Player killer = player.getKiller();
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.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
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.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.kit.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 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()
{
@ -31,7 +43,7 @@ public class PerkPassiveWoolGain extends Perk
@EventHandler
public void updateGain(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05 || !Manager.GetGame().IsLive())
if (event.getType() != UpdateType.SEC || !Manager.GetGame().IsLive())
{
return;
}
@ -43,16 +55,16 @@ public class PerkPassiveWoolGain extends Perk
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());
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())
.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.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
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.UtilItem;
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.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.newnpc.NPC;
import mineplex.core.newnpc.NewNPCManager;
@ -58,6 +62,7 @@ public class CakeShopModule extends CakeModule
.setTitle(C.cPurpleB + "Ender Pearl")
.addLore("", "Warning! Ender Pearls have a", C.cRed + "7 second" + C.cGray + " cooldown between uses.")
.build();
static final int HEALING_STATION_RADIUS = 5;
private final NewNPCManager _manager;
private final Map<NPC, CakeResource> _npcs;
@ -81,8 +86,8 @@ public class CakeShopModule extends CakeModule
// Iron Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.IRON_HELMET), 5),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.IRON_CHESTPLATE), 7),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.IRON_LEGGINGS), 7),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.IRON_CHESTPLATE), 8),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.IRON_LEGGINGS), 6),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.IRON_BOOTS), 5),
// Sword
@ -98,7 +103,7 @@ public class CakeShopModule extends CakeModule
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.IRON_AXE), 3),
// Arrow
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 15),
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 12),
// Blocks
// Wool
@ -125,8 +130,8 @@ public class CakeShopModule extends CakeModule
// Diamond Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.DIAMOND_HELMET), 10),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 20),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 20),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 24),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 16),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.DIAMOND_BOOTS), 10),
// Sword
@ -154,7 +159,7 @@ public class CakeShopModule extends CakeModule
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
// Insta-Wall
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.INSTA_WALL, 3),
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.INSTA_WALL, 2),
// Traps
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
public void playerDeath(PlayerDeathEvent event)
{

View File

@ -72,7 +72,7 @@ public enum CakeTeamItem implements CakeItem
"Resource Generator",
new ItemStack(Material.NETHER_STAR),
10,
18
20
),
REGENERATION(
"Healing Station",
@ -83,7 +83,7 @@ public enum CakeTeamItem implements CakeItem
@Override
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.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, level - 1, true, false));

View File

@ -53,7 +53,7 @@ public class CakeTeam
_chest = chest.getBlock().getLocation();
_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);
_upgrades = new HashMap<>(CakeTeamItem.values().length);

View File

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

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.game.games.turfforts;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -15,7 +14,6 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
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.entity.Arrow;
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.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
@ -50,6 +49,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
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.BlockShreadStatTracker;
import nautilus.game.arcade.stats.TheComebackStatTracker;
import net.minecraft.server.v1_8_R3.EntityArrow;
public class TurfForts extends TeamGame
{
@ -325,7 +324,6 @@ public class TurfForts extends TeamGame
return;
if (!IsAlive(event.getPlayer()))
{
event.setCancelled(true);
@ -427,27 +425,9 @@ public class TurfForts extends TeamGame
final Arrow arrow = (Arrow) event.getEntity();
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
Manager.runSyncLater(() ->
{
public void run()
{
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);
Block block = arrow.getWorld().getBlockAt(x, y, z);
Block block = UtilEnt.getHitBlock(arrow);
if (block.getTypeId() == 35)
{
@ -469,12 +449,6 @@ public class TurfForts extends TeamGame
}
arrow.remove();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}, 0);
}
@ -617,7 +591,6 @@ public class TurfForts extends TeamGame
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
@ -820,13 +793,16 @@ 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);
}
@EventHandler
public void onItem(ItemSpawnEvent e) {
if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) {
public void onItem(ItemSpawnEvent e)
{
if (e.getEntityType().equals(EntityType.DROPPED_ITEM))
{
e.setCancelled(true);
}
}

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mineplex.core.Managers;
import mineplex.core.common.util.F;
@ -32,7 +33,8 @@ import org.bukkit.inventory.meta.ItemMeta;
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 _time = 0;
@ -94,17 +96,13 @@ public class PerkFletcher extends Perk
public boolean isFletchedArrow(ItemStack stack)
{
if (!UtilGear.isMat(stack, Material.ARROW))
{
return false;
}
ItemMeta meta = stack.getItemMeta();
if (meta.getDisplayName() == null)
return false;
if (!meta.getDisplayName().contains(_name))
return false;
return true;
return meta.hasDisplayName() && meta.getDisplayName().contains(_name);
}
@EventHandler
@ -245,14 +243,10 @@ public class PerkFletcher extends Perk
public void FletchClean(UpdateEvent event)
{
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());
}
}