Skip to content

Commit

Permalink
Modified player hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
Foulest committed Oct 31, 2024
1 parent 5743fa7 commit 62e4a66
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/main/java/net/foulest/kitpvp/listeners/DeathListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ static void handleDeath(@NotNull Player receiver, boolean onPlayerQuit) {
UUID receiverBenefactor = receiverData.getBenefactor();
Kit currentKit = receiverData.getActiveKit();

// Un-hides the receiver.
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(receiver);
}

// On-death blood splatter effect.
world.playEffect(receiverLoc, Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
world.playEffect(receiverLoc, Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
Expand Down Expand Up @@ -178,8 +183,8 @@ public void run() {
}
}.runTaskLater(KitPvP.instance, 1L);

// Sends a respawn packet to the player.
NMSUtil.getConnection(receiver).a(new PacketPlayInClientCommand(PacketPlayInClientCommand.EnumClientCommand.PERFORM_RESPAWN));
// Respawn the player.
receiver.spigot().respawn();

// Teleports the player to spawn.
receiver.getInventory().setHeldItemSlot(0);
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/net/foulest/kitpvp/listeners/KitListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,17 @@ public static void onNinjaAbility(@NotNull PlayerInteractEvent event) {

// Create a task that restores the player's visibility.
TaskUtil.runTaskLater(() -> {
player.getWorld().playSound(playerLoc, Sound.BAT_IDLE, 1, 1);
MessageUtil.messagePlayer(player, "&cYou are no longer invisible.");
if (playerData.getActiveKit() instanceof Ninja) {
player.getWorld().playSound(playerLoc, Sound.BAT_IDLE, 1, 1);
MessageUtil.messagePlayer(player, "&cYou are no longer invisible.");

for (Player target : Bukkit.getOnlinePlayers()) {
if (target == player) {
continue;
}
for (Player target : Bukkit.getOnlinePlayers()) {
if (target == player) {
continue;
}

target.showPlayer(player);
target.showPlayer(player);
}
}
}, Settings.ninjaKitDuration * 20L);

Expand Down Expand Up @@ -431,16 +433,16 @@ public static void onPyroAbility(@NotNull PlayerInteractEvent event) {
player.getWorld().playEffect(playerLoc, Effect.MOBSPAWNER_FLAMES, 1);

for (Player target : nearbyPlayers) {
Location targetLoc = target.getLocation();

// Damage the target and light them on fire.
target.damage(Settings.pyroKitDamage);
target.setFireTicks(Settings.pyroKitDuration * 20);

// Play a sound to the target.
Location targetLoc = target.getLocation();
target.playSound(targetLoc, Sound.GHAST_FIREBALL, 1, 1);

// Play a particle effect at the target's location.
target.playEffect(targetLoc, Effect.MOBSPAWNER_FLAMES, 1);
MessageUtil.messagePlayer(target, "&cYou have been set on fire by a Pyro!");
}

// Sets the player's ability cooldown.
Expand Down Expand Up @@ -617,7 +619,9 @@ public static void onVampireHit(@NotNull EntityDamageByEntityEvent event) {

// Ignores ineligible players.
if (targetData.getActiveKit() == null
|| Regions.isInSafezone(targetLoc)) {
|| Regions.isInSafezone(targetLoc)
|| (target.hasPotionEffect(PotionEffectType.INVISIBILITY)
&& targetData.getActiveKit() instanceof Ninja)) {
continue;
}

Expand Down

0 comments on commit 62e4a66

Please sign in to comment.