Skip to content

Commit

Permalink
Resolves #87
Browse files Browse the repository at this point in the history
  • Loading branch information
Realizedd committed Mar 18, 2023
1 parent 671cdb1 commit 5eac866
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private void handleWin(final Player player, final Player opponent, final ArenaIm
if (InventoryUtil.addOrDrop(player, items)) {
lang.sendMessage(player, "DUEL.reward.items.message", "name", opponentName);
}
} else {
} else if (info != null) {
info.getExtra().addAll(items);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ public EssentialsHook(final DuelsPlugin plugin) {
this.config = plugin.getConfiguration();
}

@Override
public Essentials getPlugin() {
return (Essentials) super.getPlugin();
}

public void tryUnvanish(final Player player) {
if (!config.isAutoUnvanish()) {
return;
}

final Essentials plugin = (Essentials) getPlugin();
final User user = plugin.getUser(player);
final User user = getPlugin().getUser(player);

if (user != null && user.isVanished()) {
user.setVanished(false);
Expand All @@ -37,11 +41,15 @@ public void setBackLocation(final Player player, final Location location) {
return;
}

final Essentials plugin = (Essentials) getPlugin();
final User user = plugin.getUser(player);
final User user = getPlugin().getUser(player);

if (user != null) {
user.setLastLocation(location);
}
}

public boolean isVanished(final Player player) {
final User user;
return (user = getPlugin().getUser(player)) != null && user.isVanished();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import me.realized.duels.arena.MatchImpl;
import me.realized.duels.config.Config;
import me.realized.duels.config.Lang;
import me.realized.duels.hook.hooks.EssentialsHook;
import me.realized.duels.hook.hooks.MyPetHook;
import me.realized.duels.player.PlayerInfo;
import me.realized.duels.player.PlayerInfoManager;
Expand Down Expand Up @@ -65,6 +66,7 @@ public class SpectateManagerImpl implements Loadable, SpectateManager {

private Teleport teleport;
private MyPetHook myPet;
private EssentialsHook essentials;

public SpectateManagerImpl(final DuelsPlugin plugin) {
this.plugin = plugin;
Expand All @@ -81,6 +83,7 @@ public void handleLoad() {
// Late-init since SpectateManager is loaded before below variables are loaded
this.teleport = plugin.getTeleport();
this.myPet = plugin.getHookManager().getHook(MyPetHook.class);
this.essentials = plugin.getHookManager().getHook(EssentialsHook.class);
}

@Override
Expand Down Expand Up @@ -136,7 +139,7 @@ public Result startSpectating(@NotNull final Player player, @NotNull final Playe
final MatchImpl match = arena.getMatch();

// Hide from players in match
if (match != null) {
if (match != null && !essentials.isVanished(player)) {
match.getAllPlayers()
.stream()
.filter(arenaPlayer -> arenaPlayer.isOnline() && arenaPlayer.canSee(player))
Expand Down Expand Up @@ -221,7 +224,7 @@ public void stopSpectating(final Player player, final SpectatorImpl spectator) {
final MatchImpl match = spectator.getArena().getMatch();

// Show to players in match
if (match != null) {
if (match != null && !essentials.isVanished(player)) {
match.getAllPlayers()
.stream()
.filter(Player::isOnline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

public final class UUIDUtil {

private static final Pattern UUID_PATTERN = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");

private static final Pattern UUID_PATTERN = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}");
private UUIDUtil() {}

public static UUID parseUUID(final String s) {
Expand Down

0 comments on commit 5eac866

Please sign in to comment.