X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=4d39c101e9d6a58326d83c5e8283c320c2a3d493;hb=3c8d2fc3f4b11f8ccd7fcce6339ba1a34c055ac5;hp=4a71e53f9ad4fb72e4a6d63beea0bff6af1c0fa4;hpb=45803a1c678d6811f7bbf85d50c79844031be0f0;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 4a71e53..4d39c10 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -352,7 +352,9 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, * @return All Sones */ public Set getSones() { - return new HashSet(sones.values()); + synchronized (sones) { + return Collections.unmodifiableCollection(sones.values()); + } } /** @@ -372,20 +374,6 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, } /** - * Checks whether the core knows a Sone with the given ID. - * - * @param id - * The ID of the Sone - * @return {@code true} if there is a Sone with the given ID, {@code false} - * otherwise - */ - public boolean hasSone(String id) { - synchronized (sones) { - return sones.containsKey(id); - } - } - - /** * Returns all local Sones. * * @return All local Sones @@ -802,6 +790,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, sone.setClient(new Client("Sone", SonePlugin.VERSION.toString())); sone.setKnown(true); /* TODO - load posts ’n stuff */ + trustedIdentities.put(ownIdentity, Collections.synchronizedSet(new HashSet())); sones.put(ownIdentity.getId(), sone); final SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, sone); soneInserters.put(sone, soneInserter); @@ -2236,7 +2225,6 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, OwnIdentity ownIdentity = ownIdentityAddedEvent.ownIdentity(); logger.log(Level.FINEST, String.format("Adding OwnIdentity: %s", ownIdentity)); if (ownIdentity.hasContext("Sone")) { - trustedIdentities.put(ownIdentity, Collections.synchronizedSet(new HashSet())); addLocalSone(ownIdentity); } }