-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathEntityNameUtils.java
More file actions
20 lines (15 loc) · 902 Bytes
/
EntityNameUtils.java
File metadata and controls
20 lines (15 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.froobworld.farmcontrol.utils;
import com.froobworld.farmcontrol.controller.entity.SnapshotEntity;
import java.util.function.Predicate;
public final class EntityNameUtils {
public static Predicate<SnapshotEntity> fromString(String string) {
if (string.startsWith("*")) {
String name = string.split("\\*")[1];
return entity -> entity.getEntity().getCustomName() != null && entity.getEntity().getCustomName().toLowerCase().endsWith(name.toLowerCase());
} else if (string.endsWith("*")) {
String name = string.split("\\*")[0];
return entity -> entity.getEntity().getCustomName() != null && entity.getEntity().getCustomName().toLowerCase().startsWith(name.toLowerCase());
}
return entity -> entity.getEntity().getCustomName() != null && entity.getEntity().getCustomName().equalsIgnoreCase(string);
}
}