X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FSoneAccessor.java;h=60e2e9be7312972ffcdf4aa0a5a978709009b0b4;hb=9e8288cad876b3c86ce3bbd1a7daaee8d32137e2;hp=dc4c0abab6a675d395ff7116a5c429dd6893c75f;hpb=9d9ede6b0344ef1edf8af5bd32e59797d216b6c4;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
index dc4c0ab..60e2e9b 100644
--- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
+++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
@@ -17,6 +17,8 @@
package net.pterodactylus.sone.template;
+import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.core.Core.SoneStatus;
import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.template.Accessor;
@@ -29,11 +31,11 @@ import net.pterodactylus.util.template.ReflectionAccessor;
*
niceName
* Will show a combination of first name, middle name, and last name, if
* available, otherwise the username of the Sone is returned.
- * isFriend
+ * friend
* Will return {@code true} if the sone in question is a friend of the
* currently logged in Sone (as determined by accessing the âcurrentSoneâ
* variable of the given {@link DataProvider}).
- * isCurrent
+ * current
* Will return {@code true} if the sone in question is the currently logged
* in Sone.
*
@@ -42,6 +44,19 @@ import net.pterodactylus.util.template.ReflectionAccessor;
*/
public class SoneAccessor extends ReflectionAccessor {
+ /** The core. */
+ private final Core core;
+
+ /**
+ * Creates a new Sone accessor.
+ *
+ * @param core
+ * The Sone core
+ */
+ public SoneAccessor(Core core) {
+ this.core = core;
+ }
+
/**
* {@inheritDoc}
*/
@@ -50,15 +65,27 @@ public class SoneAccessor extends ReflectionAccessor {
Sone sone = (Sone) object;
if (member.equals("niceName")) {
return getNiceName(sone);
- } else if (member.equals("isFriend")) {
+ } else if (member.equals("friend")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
- return currentSone.hasFriend(sone) ? true : null;
- } else if (member.equals("isCurrent")) {
+ return (currentSone != null) && currentSone.hasFriend(sone);
+ } else if (member.equals("current")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
- return currentSone.equals(sone);
- } else if (member.equals("isBlocked")) {
+ return (currentSone != null) && currentSone.equals(sone);
+ } else if (member.equals("blocked")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
- return currentSone.isSoneBlocked(sone.getId());
+ return (currentSone != null) && currentSone.isSoneBlocked(sone.getId());
+ } else if (member.equals("modified")) {
+ return sone.getModificationCounter() > 0;
+ } else if (member.equals("status")) {
+ return core.getSoneStatus(sone).toString();
+ } else if (member.equals("unknown")) {
+ return core.getSoneStatus(sone) == SoneStatus.unknown;
+ } else if (member.equals("idle")) {
+ return core.getSoneStatus(sone) == SoneStatus.idle;
+ } else if (member.equals("inserting")) {
+ return core.getSoneStatus(sone) == SoneStatus.inserting;
+ } else if (member.equals("downloading")) {
+ return core.getSoneStatus(sone) == SoneStatus.downloading;
}
return super.get(dataProvider, object, member);
}