23 lines
874 B
Java
23 lines
874 B
Java
package games.dmg.spigotignis;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
|
|
/** Server-thread ownership of this plugin's effective invisibility contribution. */
|
|
public final class EffectOwnership {
|
|
private final Set<UUID> applying = new HashSet<>();
|
|
private final Set<UUID> owned = new HashSet<>();
|
|
|
|
public void applying(UUID player, boolean active) {
|
|
if (active) applying.add(player); else applying.remove(player);
|
|
}
|
|
public void changed(UUID player, boolean actuallyChanged, boolean remainsPresent) {
|
|
if (!actuallyChanged) return;
|
|
if (remainsPresent && applying.contains(player)) owned.add(player);
|
|
else owned.remove(player);
|
|
}
|
|
public boolean owns(UUID player) { return owned.contains(player); }
|
|
public void forget(UUID player) { applying.remove(player); owned.remove(player); }
|
|
}
|