Always provide a copy of the placeholder map

This commit is contained in:
extendedclip 2020-08-03 13:54:28 -04:00
parent 12a358fbd0
commit 51844cd291

View File

@ -20,6 +20,7 @@
package me.clip.placeholderapi.expansion.manager;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.io.File;
@ -114,17 +115,14 @@ public final class LocalExpansionManager implements Listener {
return ImmutableSet.copyOf(expansions.values());
}
@Nullable
public PlaceholderExpansion getExpansion(@NotNull final String identifier) {
return expansions.get(identifier.toLowerCase());
return ImmutableMap.copyOf(expansions).get(identifier.toLowerCase());
}
@NotNull
public Optional<PlaceholderExpansion> findExpansionByName(@NotNull final String name) {
return expansions.values().stream()
.filter(expansion -> name.equalsIgnoreCase(expansion.getName())).findFirst();
return getExpansions().stream().filter(expansion -> name.equalsIgnoreCase(expansion.getName())).findFirst();
}
@NotNull