Skip to content

Commit af09374

Browse files
committed
Don't send a blank (unload) resource pack if they already have one applied
1 parent ae5553b commit af09374

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • velocity/src/main/java/com/convallyria/forcepack/velocity/handler

velocity/src/main/java/com/convallyria/forcepack/velocity/handler/PackHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,24 @@ public void setPack(final Player player, final ServerInfo serverInfo) {
7171
applying.add(player.getUniqueId());
7272
task.set(builder.schedule());
7373
}, () -> {
74+
final ResourcePackInfo appliedResourcePack = player.getAppliedResourcePack();
7475
// This server doesn't have a pack set - send unload pack if enabled and if they already have one
75-
if (player.getAppliedResourcePack() == null) return;
76+
if (appliedResourcePack == null) return;
77+
7678
final VelocityConfig unloadPack = plugin.getConfig().getConfig("unload-pack");
7779
final boolean enableUnload = unloadPack.getBoolean("enable");
7880
if (!enableUnload) return;
7981

8082
final List<String> excluded = unloadPack.getStringList("exclude");
8183
if (excluded.contains(serverInfo.getName())) return;
8284

83-
plugin.getPackByServer(ForcePackVelocity.EMPTY_SERVER_NAME).ifPresent(empty -> empty.setResourcePack(player.getUniqueId()));
85+
plugin.getPackByServer(ForcePackVelocity.EMPTY_SERVER_NAME).ifPresent(empty -> {
86+
// If their current applied resource pack is the unloaded one, don't send it again
87+
// Checking URL rather than hash should be fine... it's simpler and should be unique.
88+
if (appliedResourcePack.getUrl().equals(empty.getURL())) return;
89+
90+
empty.setResourcePack(player.getUniqueId());
91+
});
8492
});
8593
}
8694
}

0 commit comments

Comments
 (0)