diff --git a/src/main/java/me/lrxh/practice/match/Match.java b/src/main/java/me/lrxh/practice/match/Match.java index 26bc30e..cce0910 100644 --- a/src/main/java/me/lrxh/practice/match/Match.java +++ b/src/main/java/me/lrxh/practice/match/Match.java @@ -418,9 +418,12 @@ public void run() { if (countdown > 0) { player.sendMessage(Locale.MATCH_RESPAWN_TIMER.format(player, countdown)); player.playSound(player.getLocation(), Sound.NOTE_PLING, 10, 1); + if(!gamePlayer.isRespawned()){ + gamePlayer.setRespawned(false); + this.cancel(); + } countdown--; } else { - showPlayer(playerUUID); player.sendMessage(Locale.MATCH_RESPAWNED.format(player)); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 1); player.setAllowFlight(false); @@ -429,9 +432,13 @@ public void run() { Location spawn = aTeam ? getArena().getSpawnA() : getArena().getSpawnB(); player.teleport(spawn); player.getInventory().setArmorContents(InventoryUtil.color(gamePlayer.getKitLoadout().getArmor(), aTeam ? Color.RED : Color.BLUE).toArray(new ItemStack[0])); - player.getInventory().setContents(gamePlayer.getKitLoadout().getContents()); + //player.getInventory().setContents(gamePlayer.getKitLoadout().getContents()); + player.getInventory().setContents(InventoryUtil.color(gamePlayer.getKitLoadout().getContents(), aTeam ? Color.RED : Color.BLUE).toArray(new ItemStack[0])); + player.setGameMode(GameMode.SURVIVAL); gamePlayer.setRespawned(false); + PlayerUtil.setImmune(player, 30); + showPlayer(playerUUID); this.cancel(); } } diff --git a/src/main/java/me/lrxh/practice/match/MatchListener.java b/src/main/java/me/lrxh/practice/match/MatchListener.java index 5f3d72b..d970057 100644 --- a/src/main/java/me/lrxh/practice/match/MatchListener.java +++ b/src/main/java/me/lrxh/practice/match/MatchListener.java @@ -88,9 +88,21 @@ public void onBlockPlaceEvent(BlockPlaceEvent event) { } Arena arena = match.getArena(); + Location blockLocation = event.getBlockPlaced().getLocation(); int x = (int) event.getBlockPlaced().getLocation().getX(); int y = (int) event.getBlockPlaced().getLocation().getY(); int z = (int) event.getBlockPlaced().getLocation().getZ(); + Location newBlockLocation = new Location(arena.getWorld(), x, y, z); + event.getPlayer().sendMessage(newBlockLocation.toString()); + if (newBlockLocation.equals(new Location(arena.getSpawnA().getWorld(), (int) arena.getSpawnA().getX(), (int) arena.getSpawnA().getY(), (int) arena.getSpawnA().getZ())) + || newBlockLocation.equals(new Location(arena.getSpawnB().getWorld(), (int) arena.getSpawnB().getX(), (int) arena.getSpawnB().getY(), (int) arena.getSpawnB().getZ())) + || newBlockLocation.equals(new Location(arena.getSpawnA().getWorld(), (int) arena.getSpawnA().getX(), (int) arena.getSpawnA().getY() + 1, (int) arena.getSpawnA().getZ())) + || newBlockLocation.equals(new Location(arena.getSpawnB().getWorld(), (int) arena.getSpawnB().getX(), (int) arena.getSpawnB().getY() + 1, (int) arena.getSpawnB().getZ()))){ + + event.getPlayer().sendMessage(CC.translate("&cYou cannot place block blocks here!")); + event.setCancelled(true); + return; + } if (y > arena.getMaxBuildHeight()) { event.getPlayer().sendMessage(CC.RED + "You have reached the maximum build height."); @@ -100,7 +112,7 @@ public void onBlockPlaceEvent(BlockPlaceEvent event) { if (x >= arena.getX1() && x <= arena.getX2() && y >= arena.getY1() && y <= arena.getY2() && z >= arena.getZ1() && z <= arena.getZ2()) { - match.getPlacedBlocks().add(event.getBlock().getLocation()); + match.getPlacedBlocks().add(blockLocation); } else { event.getPlayer().sendMessage(CC.RED + "You cannot build outside of the arena!"); event.setCancelled(true); @@ -704,7 +716,7 @@ public void onPlayerInteractEvent(PlayerInteractEvent event) { profile.getMatch().getGamePlayer(player).setKitLoadout(kitLoadout); GameParticipant participantA = match.getParticipantA(); player.getInventory().setArmorContents(InventoryUtil.color(kitLoadout.getArmor(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0])); - player.getInventory().setContents(kitLoadout.getContents()); + player.getInventory().setContents(InventoryUtil.color(kitLoadout.getContents(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0])); player.updateInventory(); event.setCancelled(true); } diff --git a/src/main/java/me/lrxh/practice/util/InventoryUtil.java b/src/main/java/me/lrxh/practice/util/InventoryUtil.java index bb71fd2..7eff7ca 100644 --- a/src/main/java/me/lrxh/practice/util/InventoryUtil.java +++ b/src/main/java/me/lrxh/practice/util/InventoryUtil.java @@ -4,6 +4,7 @@ import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.meta.ItemMeta; @@ -256,6 +257,12 @@ public static List color(ItemStack[] itemStackList, Color color) { LeatherArmorMeta meta = (LeatherArmorMeta) itemStack.getItemMeta(); meta.setColor(color); itemStack.setItemMeta(meta); + } else if (itemStack.getType() == Material.WOOL) { + if (color.equals(Color.BLUE)){ + itemStack.setDurability((short) 11); + }else{ + itemStack.setDurability((short) 14); + } } items.add(itemStack); } diff --git a/src/main/java/me/lrxh/practice/util/PlayerUtil.java b/src/main/java/me/lrxh/practice/util/PlayerUtil.java index 49cf52d..1bdf4f0 100644 --- a/src/main/java/me/lrxh/practice/util/PlayerUtil.java +++ b/src/main/java/me/lrxh/practice/util/PlayerUtil.java @@ -47,6 +47,10 @@ public void setLastAttacker(Player victim, Player attacker) { victim.setMetadata("lastAttacker", new FixedMetadataValue(Practice.getInstance(), attacker.getUniqueId())); } + public static void setImmune(Player player, int ticks) { + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, ticks, 250)); + } + public Player getLastAttacker(Player victim) { if (victim.hasMetadata("lastAttacker")) { return Bukkit.getPlayer((UUID) victim.getMetadata("lastAttacker").get(0).value());