Make Sponge's #getFriendlyIdentifier return usernames of Users and display names of Groups (#412)

This commit is contained in:
Luck 2017-08-03 18:39:39 +01:00
parent 3d2115ff3c
commit 5784458d03
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 12 additions and 1 deletions

View File

@ -153,6 +153,11 @@ public class SubjectProxy implements Subject {
return ref.getSubjectIdentifier(); return ref.getSubjectIdentifier();
} }
@Override
public Optional<String> getFriendlyIdentifier() {
return getHandle().thenApply(LPSubject::getFriendlyIdentifier).join();
}
@Override @Override
public Set<Context> getActiveContexts() { public Set<Context> getActiveContexts() {
return getHandle().thenApply(handle -> CompatibilityUtil.convertContexts(handle.getActiveContextSet())).join(); return getHandle().thenApply(handle -> CompatibilityUtil.convertContexts(handle.getActiveContextSet())).join();

View File

@ -150,7 +150,8 @@ public class SpongeGroup extends Group {
@Override @Override
public Optional<String> getFriendlyIdentifier() { public Optional<String> getFriendlyIdentifier() {
return Optional.of(parent.getFriendlyName()); String rawDisplayName = parent.getRawDisplayName();
return rawDisplayName.equals(getIdentifier()) ? Optional.empty() : Optional.of(rawDisplayName);
} }
@Override @Override

View File

@ -94,6 +94,11 @@ public class SpongeUser extends User {
return plugin.getUuidCache().getExternalUUID(parent.getUuid()).toString(); return plugin.getUuidCache().getExternalUUID(parent.getUuid()).toString();
} }
@Override
public Optional<String> getFriendlyIdentifier() {
return parent.getName();
}
@Override @Override
public Optional<CommandSource> getCommandSource() { public Optional<CommandSource> getCommandSource() {
final UUID uuid = plugin.getUuidCache().getExternalUUID(parent.getUuid()); final UUID uuid = plugin.getUuidCache().getExternalUUID(parent.getUuid());