1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Use newSetFromMap

This commit is contained in:
Tim203
2022-12-27 12:05:47 +01:00
parent e502e0019f
commit c84dd0cae5

View File

@@ -35,21 +35,21 @@ import org.geysermc.floodgate.api.inject.InjectorAddon;
import org.geysermc.floodgate.api.inject.PlatformInjector; import org.geysermc.floodgate.api.inject.PlatformInjector;
public abstract class CommonPlatformInjector implements PlatformInjector { public abstract class CommonPlatformInjector implements PlatformInjector {
private final Map<Channel, ?> injectedClients = private final Set<Channel> injectedClients =
Collections.synchronizedMap(new WeakHashMap<>()); Collections.synchronizedSet(Collections.newSetFromMap(new WeakHashMap<>()));
private final Map<Class<?>, InjectorAddon> addons = new HashMap<>(); private final Map<Class<?>, InjectorAddon> addons = new HashMap<>();
protected boolean addInjectedClient(Channel channel) { protected boolean addInjectedClient(Channel channel) {
return injectedClients.put(channel, null) != null; return injectedClients.add(channel);
} }
public boolean removeInjectedClient(Channel channel) { public boolean removeInjectedClient(Channel channel) {
return injectedClients.remove(channel) != null; return injectedClients.remove(channel);
} }
public Set<Channel> injectedClients() { public Set<Channel> injectedClients() {
return injectedClients.keySet(); return injectedClients;
} }
@Override @Override