()
| 167 | } |
| 168 | |
| 169 | private PlayerOwner intern() { |
| 170 | String name = getOwnerName(); |
| 171 | UUID uuid = owner.getId(); |
| 172 | if (StringUtils.isNullOrEmpty(name)) { |
| 173 | PlayerOwner existing = CACHE_UUID.getIfPresent(uuid); |
| 174 | if (existing == null) { |
| 175 | CACHE_UUID.put(uuid, this); |
| 176 | return this; |
| 177 | } else { |
| 178 | return existing; |
| 179 | } |
| 180 | |
| 181 | } else if (uuid == null) { |
| 182 | PlayerOwner existing = CACHE_NAME.getIfPresent(name); |
| 183 | if (existing == null) { |
| 184 | CACHE_NAME.put(name, this); |
| 185 | return this; |
| 186 | } else { |
| 187 | return existing; |
| 188 | } |
| 189 | } else { |
| 190 | // Both UUID and name are here |
| 191 | PlayerOwner fromUUID = CACHE_UUID.getIfPresent(uuid); |
| 192 | PlayerOwner fromName = CACHE_NAME.getIfPresent(name); |
| 193 | if (fromUUID == null && fromName != null) { |
| 194 | CACHE_UUID.put(uuid, fromName); |
| 195 | return fromName; |
| 196 | } else if (fromUUID != null && fromName == null) { |
| 197 | CACHE_NAME.put(name, fromUUID); |
| 198 | return fromUUID; |
| 199 | } else if (fromUUID == fromName) { |
| 200 | return fromName; |
| 201 | } else { |
| 202 | // Uh oh, thats not good- somehow two separate entries exist with the same properties. |
| 203 | // Don't require a debug symbol b/c I'm interested in if this actually happens in the wild |
| 204 | String data = "[N=" + System.identityHashCode(fromName) + ", O=" + System.identityHashCode(fromUUID) + "]"; |
| 205 | BCLog.logger.warn("[lib.perm.owner] Found 2 different (but identical) PlayerOwner objects! Odd... " + data); |
| 206 | CACHE_NAME.put(name, fromUUID); |
| 207 | return fromUUID; |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | public String toString() { |
no test coverage detected