Skip to content

Commit

Permalink
Skip loop if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 committed Sep 16, 2024
1 parent 3ba0458 commit 05ed4e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.yescallop.essentialsnk</groupId>
<artifactId>essentialsnk</artifactId>
<version>1.9.2-IGN.23</version>
<version>1.9.2-IGN.24</version>

<name>EssentialsNK</name>
<description>Essential commands for your server</description>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/cn/yescallop/essentialsnk/EssentialsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class EssentialsAPI {
private final List<TPCooldown> tpCooldowns = new ArrayList<>();
private final Map<Player, Location> playerLastLocation = new ConcurrentHashMap<>();
private final Map<Integer, TPRequest> tpRequests = new ConcurrentHashMap<>();
private final Set<String> vanishedPlayers = ConcurrentHashMap.newKeySet();
final Set<String> vanishedPlayers = ConcurrentHashMap.newKeySet();
private final Map<String, String> lastMessagedPlayers = new ConcurrentHashMap<>();

private final ConfigType homeConfig = null;
Expand Down Expand Up @@ -304,6 +304,9 @@ public void removeTPRequestBetween(Player from, Player to) {
}

public void removeTPRequest(Player player) {
if (this.tpRequests.isEmpty()) {
return;
}
this.tpRequests.values().removeIf(request -> request.getSender() == player || request.getRecipient() == player);
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cn/yescallop/essentialsnk/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
boolean vanished = api.isVanished(player);
if (!vanished && EssentialsAPI.getInstance().vanishedPlayers.isEmpty()) {
return;
}
for (Player p : api.getServer().getOnlinePlayers().values()) {
if (api.isVanished(p)) {
player.hidePlayer(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cn.nukkit.command.Command;
import cn.nukkit.command.CommandMap;
import cn.nukkit.command.SimpleCommandMap;
import cn.yescallop.essentialsnk.EssentialsAPI;
import cn.yescallop.essentialsnk.command.defaults.*;
import cn.yescallop.essentialsnk.command.defaults.teleport.*;
Expand Down

0 comments on commit 05ed4e5

Please sign in to comment.