-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/uuid/BukkitPlayerDB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package us.talabrek.ultimateskyblock.uuid; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Non performing PlayerDB that goes directly to the Bukkit implementation | ||
*/ | ||
public class BukkitPlayerDB implements PlayerDB { | ||
@Override | ||
public UUID getUUIDFromName(String name) { | ||
if (UNKNOWN_PLAYER_NAME.equalsIgnoreCase(name)) { | ||
return UNKNOWN_PLAYER_UUID; | ||
} | ||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name); | ||
return offlinePlayer != null ? offlinePlayer.getUniqueId() : null; | ||
} | ||
|
||
@Override | ||
public UUID getUUIDFromName(String name, boolean lookup) { | ||
return getUUIDFromName(name); | ||
} | ||
|
||
@Override | ||
public String getName(UUID uuid) { | ||
if (UNKNOWN_PLAYER_UUID.equals(uuid)) { | ||
return UNKNOWN_PLAYER_NAME; | ||
} | ||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); | ||
return offlinePlayer != null ? offlinePlayer.getName() : null; | ||
} | ||
|
||
@Override | ||
public String getDisplayName(UUID uuid) { | ||
Player player = Bukkit.getPlayer(uuid); | ||
return player != null ? player.getDisplayName() : null; | ||
} | ||
|
||
@Override | ||
public String getDisplayName(String playerName) { | ||
Player player = Bukkit.getPlayer(playerName); | ||
return player != null ? player.getDisplayName() : null; | ||
} | ||
|
||
@Override | ||
public Set<String> getNames(String search) { | ||
Set<String> names = new HashSet<>(); | ||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers(); | ||
for (Player player : onlinePlayers) { | ||
if (player != null && player.isOnline() && player.getName() != null) { | ||
names.add(player.getName()); | ||
} | ||
} | ||
return names; | ||
} | ||
|
||
@Override | ||
public void updatePlayer(UUID uuid, String name, String displayName) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public Player getPlayer(UUID uuid) { | ||
return Bukkit.getPlayer(uuid); | ||
} | ||
|
||
@Override | ||
public Player getPlayer(String name) { | ||
return Bukkit.getPlayer(name); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
// Do nothing | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,4 +299,4 @@ diminishingReturns: | |
'192': 5000 | ||
negativeReturns: | ||
'154': 5 | ||
version: 8 | ||
version: 9 |