Skip to content

Commit

Permalink
add remove_npcs_from_playerlist_delay config option
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Aug 30, 2024
1 parent 6a10f66 commit 3487530
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface FancyNpcsConfig {

int getVisibilityDistance();

int getRemoveNpcsFromPlayerlistDelay();

List<String> getBlockedCommands();

Map<String, Integer> getMaxNpcsPerPermission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void spawn(Player player) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, 2, TimeUnit.SECONDS);
}, FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay(), TimeUnit.MILLISECONDS);

update(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void spawn(Player player) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, 2, TimeUnit.SECONDS);
}, FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay(), TimeUnit.MILLISECONDS);

update(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void spawn(Player player) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, 2, TimeUnit.SECONDS);
}, FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay(), TimeUnit.MILLISECONDS);

update(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void spawn(Player player) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, 2, TimeUnit.SECONDS);
}, FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay(), TimeUnit.MILLISECONDS);

update(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void spawn(Player player) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, 2, TimeUnit.SECONDS);
}, FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay(), TimeUnit.MILLISECONDS);

update(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void spawn(Player player) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, 2, TimeUnit.SECONDS);
}, FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay(), TimeUnit.MILLISECONDS);

update(player);
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/de/oliver/fancynpcs/FancyNpcsConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig {
*/
private int visibilityDistance;

/**
* The delay in ticks to remove NPCs from the player list.
* Increase this value if you have problems with skins not loading correctly when joining or switching worlds.
*/
private int removeNpcsFromPlayerlistDelay;

/**
* The commands that are blocked for NPCs in the message.
*/
Expand Down Expand Up @@ -106,6 +112,9 @@ public void reload() {
visibilityDistance = (int) ConfigHelper.getOrDefault(config, "visibility_distance", 20);
config.setInlineComments("visibility_distance", List.of("The distance at which NPCs are visible."));

removeNpcsFromPlayerlistDelay = (int) ConfigHelper.getOrDefault(config, "remove_npcs_from_playerlist_delay", 2000);
config.setInlineComments("remove_npcs_from_playerlist_delay", List.of("The delay in ticks to remove NPCs from the player list. Increase this value if you have problems with skins not loading correctly when joining or switching worlds."));

blockedCommands = (List<String>) ConfigHelper.getOrDefault(config, "blocked_commands", Arrays.asList("op", "ban"));
config.setInlineComments("blocked_commands", List.of("The commands that are blocked for NPCs in the message."));

Expand Down Expand Up @@ -168,6 +177,10 @@ public int getVisibilityDistance() {
return visibilityDistance;
}

public int getRemoveNpcsFromPlayerlistDelay() {
return removeNpcsFromPlayerlistDelay;
}

public List<String> getBlockedCommands() {
return blockedCommands;
}
Expand Down

0 comments on commit 3487530

Please sign in to comment.