Made matchmaker null safe, bump the version
This commit is contained in:
parent
4368601532
commit
c7b36aadca
2 changed files with 24 additions and 13 deletions
|
@ -2,6 +2,6 @@
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
# Properties
|
# Properties
|
||||||
mod_version=1.1.0
|
mod_version=1.1.1
|
||||||
maven_group=arzumify.presence
|
maven_group=arzumify.presence
|
||||||
archives_base_name=presence
|
archives_base_name=presence
|
|
@ -25,26 +25,37 @@ public class MatchMaker<P extends Presence<P>, T extends PresenceProvider<P>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<T> Search(T match, Channel channel) {
|
public Set<T> Search(T match, Channel channel) {
|
||||||
Set<T> matches = new HashSet<>();
|
var matches = new HashSet<T>();
|
||||||
Set<Vec2i> presenceChunks = match.presence().GetCollisionChunks();
|
var presenceChunks = match.presence().GetCollisionChunks();
|
||||||
if (!Collections.disjoint(presenceChunks, channels.get(channel).keySet())) {
|
var chunks = channels.get(channel);
|
||||||
presenceChunks.retainAll(channels.get(channel).keySet());
|
if (chunks != null) {
|
||||||
for (Vec2i chunk : presenceChunks) {
|
if (!Collections.disjoint(presenceChunks, chunks.keySet())) {
|
||||||
for (T matching : channels.get(channel).get(chunk)) {
|
presenceChunks.retainAll(chunks.keySet());
|
||||||
if (match != matching) {
|
for (Vec2i chunk : presenceChunks) {
|
||||||
if (match.presence().Matches(matching.presence())) {
|
if (chunks.get(chunk) != null) {
|
||||||
matches.add(matching);
|
for (T matching : chunks.get(chunk)) {
|
||||||
|
if (match != matching) {
|
||||||
|
if (match.presence().Matches(matching.presence())) {
|
||||||
|
matches.add(matching);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return matches;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return matches;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(T match, Channel channel) {
|
public void Remove(T match, Channel channel) {
|
||||||
for (Vec2i chunk : match.presence().GetChunks()) {
|
for (Vec2i chunk : match.presence().GetChunks()) {
|
||||||
channels.get(channel).get(chunk).remove(match);
|
if (channels.get(channel) != null) {
|
||||||
|
if (channels.get(channel).get(chunk) != null) {
|
||||||
|
channels.get(channel).get(chunk).remove(match);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue