X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FSoneAccessor.java;h=beb7f2ae05ab55395d88917d59861d44de817d11;hb=415b8c3b295775d66fb1db1d0f641e05fbbcca98;hp=c4eac6c73cae5d43062ecf10ae0651381111ee5e;hpb=4a2fdf3b0b3dfcfc761c83797018237ec4c82a4b;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 c4eac6c..beb7f2a 100644 --- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java @@ -21,6 +21,7 @@ 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.sone.freenet.wot.Trust; import net.pterodactylus.util.template.Accessor; import net.pterodactylus.util.template.DataProvider; import net.pterodactylus.util.template.ReflectionAccessor; @@ -68,10 +69,10 @@ public class SoneAccessor extends ReflectionAccessor { } else if (member.equals("local")) { return sone.getInsertUri() != null; } else if (member.equals("friend")) { - Sone currentSone = (Sone) dataProvider.getData("currentSone"); + Sone currentSone = (Sone) dataProvider.get("currentSone"); return (currentSone != null) && currentSone.hasFriend(sone.getId()); } else if (member.equals("current")) { - Sone currentSone = (Sone) dataProvider.getData("currentSone"); + Sone currentSone = (Sone) dataProvider.get("currentSone"); return (currentSone != null) && currentSone.equals(sone); } else if (member.equals("modified")) { return core.isModifiedSone(sone); @@ -90,8 +91,14 @@ public class SoneAccessor extends ReflectionAccessor { } else if (member.equals("locked")) { return core.isLocked(sone); } else if (member.equals("trust")) { - Sone currentSone = (Sone) dataProvider.getData("currentSone"); - return core.getTrust(currentSone, sone); + Sone currentSone = (Sone) dataProvider.get("currentSone"); + if (currentSone == null) { + return null; + } + Trust trust = core.getTrust(currentSone, sone); + if (trust == null) { + return new Trust(null, null, null); + } } return super.get(dataProvider, object, member); }