Skip to content

Commit

Permalink
fix: RequestManager requesting data from Mojang servers
Browse files Browse the repository at this point in the history
  • Loading branch information
RoinujNosde committed Dec 26, 2024
1 parent 9097fa0 commit b37512b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ public ClanPlayer getAnyClanPlayer(String playerName) {
/**
* Gets the ClanPlayer object for the player, creates one if not found
*/
@Deprecated
public @Nullable ClanPlayer getCreateClanPlayerUUID(String playerName) {
UUID playerUniqueId = UUIDMigration.getForcedPlayerUUID(playerName);
if (playerUniqueId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.sacredlabyrinth.phaed.simpleclans.events.RequestFinishedEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.WarEndEvent;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -45,7 +44,7 @@ public void addDemoteRequest(ClanPlayer requester, String demotedName, Clan clan
}
String msg = MessageFormat.format(lang("asking.for.the.demotion"), requester.getName(), demotedName);

ClanPlayer demotedTp = plugin.getClanManager().getClanPlayer(UUIDMigration.getForcedPlayerUUID(demotedName));
ClanPlayer demotedTp = plugin.getClanManager().getAnyClanPlayer(demotedName);

List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(clan.getLeaders());
acceptors.remove(demotedTp);
Expand Down Expand Up @@ -250,8 +249,9 @@ public void processResults(Request req) {
@Nullable
Clan targetClan = plugin.getClanManager().getClan(target);

ClanPlayer targetCp = plugin.getClanManager().getAnyClanPlayer(target);
@Nullable
UUID targetPlayer = UUIDMigration.getForcedPlayerUUID(target);
UUID targetUuid = targetCp != null ? targetCp.getUniqueId() : null;

List<String> accepts = req.getAccepts();
List<String> denies = req.getDenies();
Expand All @@ -271,16 +271,16 @@ public void processResults(Request req) {
break;
case DEMOTE:
case PROMOTE:
if (!req.votingFinished() || targetPlayer == null) {
if (!req.votingFinished() || targetUuid == null) {
return;
}
target = requestClan.getTag();

if (req.getType() == ClanRequest.DEMOTE) {
processDemote(req, requestClan, targetPlayer, denies);
processDemote(req, requestClan, targetUuid, denies);
}
if (req.getType() == ClanRequest.PROMOTE) {
processPromote(req, requestClan, targetPlayer, denies);
processPromote(req, requestClan, targetUuid, denies);
}
break;
case DISBAND:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.YAMLSerializer;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDFetcher;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -60,21 +59,15 @@ public StorageManager() {
* @return the ChatBlock
*/
public ChatBlock getChatBlock(Player player) {
return chatBlocks.get(player.getUniqueId().toString());
return chatBlocks.get(player.getName());
}

/**
* Store pending chat lines for a player
*
*/
public void addChatBlock(CommandSender player, ChatBlock cb) {
UUID uuid = UUIDMigration.getForcedPlayerUUID(player.getName());

if (uuid == null) {
return;
}

chatBlocks.put(uuid.toString(), cb);
chatBlocks.put(player.getName(), cb);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static boolean canReturnUUID() {
}
}

@Deprecated
public static UUID getForcedPlayerUUID(String playerName) {
Player player = Bukkit.getPlayerExact(playerName);

Expand Down

0 comments on commit b37512b

Please # to comment.