mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Port OfflinePlayerUUIDService to the new system
This commit is contained in:
parent
29f2863cf4
commit
64cfe240f9
@ -25,12 +25,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.uuid;
|
package com.plotsquared.bukkit.uuid;
|
||||||
|
|
||||||
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
import com.plotsquared.core.uuid.UUIDService;
|
import com.plotsquared.core.uuid.UUIDService;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,20 +40,26 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class OfflinePlayerUUIDService implements UUIDService {
|
public class OfflinePlayerUUIDService implements UUIDService {
|
||||||
|
|
||||||
@Override @NotNull public Optional<String> get(@NotNull final UUID uuid) {
|
@Override public @NotNull List<UUIDMapping> getNames(@NotNull List<UUID> uuids) {
|
||||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
|
final List<UUIDMapping> wrappers = new ArrayList<>(uuids.size());
|
||||||
if (offlinePlayer.hasPlayedBefore()) {
|
for (final UUID uuid : uuids) {
|
||||||
return Optional.ofNullable(offlinePlayer.getName());
|
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
|
||||||
|
if (offlinePlayer.hasPlayedBefore()) {
|
||||||
|
wrappers.add(new UUIDMapping(uuid, offlinePlayer.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return wrappers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull public Optional<UUID> get(@NotNull final String username) {
|
@Override public @NotNull List<UUIDMapping> getUUIDs(@NotNull List<String> usernames) {
|
||||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(username);
|
final List<UUIDMapping> wrappers = new ArrayList<>(usernames.size());
|
||||||
if (offlinePlayer.hasPlayedBefore()) {
|
for (final String username : usernames) {
|
||||||
return Optional.of(offlinePlayer.getUniqueId());
|
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(username);
|
||||||
|
if (offlinePlayer.hasPlayedBefore()) {
|
||||||
|
wrappers.add(new UUIDMapping(offlinePlayer.getUniqueId(), offlinePlayer.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return wrappers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user