Fixing Party Chat Bug

This commit is contained in:
nossr50 2019-04-11 03:49:13 -07:00
parent 87bf3a5b40
commit 8b0a580505
4 changed files with 15 additions and 5 deletions

View File

@ -8,10 +8,12 @@ Key:
- Removal
Version 2.1.40
(API) mcMMO will now return null in all cases for UserManager.getPlayerProfile() if they have not been loaded yet
Added new locale string "Profile.Loading.FailureNotice"
Added new locale string "Profile.Loading.FailurePlayer"
mcMMO no longer gives up forever if a player profile fails to load and the player is still online
mcMMO will attempt to save a profile up to 10 times now, previously it would only try one time.
Fixed an ArrayIndexOutOfBounds error with Party Chat
Player data for mcMMO is now loaded 3 seconds after a player connects in order to give any ongoing save tasks from other servers a small grace period to finish. This will mostly be useful to Bungee servers.
NOTES: I received reports from some users saying that saving and loading was failing could fail and not recover, I have implemented some fail safes to greatly reduce the the odds of that happening.

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.40-SNAPSHOT</version>
<version>2.1.40</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
@ -46,12 +48,14 @@ public abstract class ChatManager {
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
//Find the people with permissions
for(Player player : event.getPlugin().getServer().getOnlinePlayers())
for(McMMOPlayer mcMMOPlayer : UserManager.getPlayers())
{
Player player = mcMMOPlayer.getPlayer();
//Check for toggled players
if(UserManager.getPlayer(player).isPartyChatSpying())
if(mcMMOPlayer.isPartyChatSpying())
{
Party adminParty = UserManager.getPlayer(player).getParty();
Party adminParty = mcMMOPlayer.getParty();
//Only message admins not part of this party
if(adminParty != null)

View File

@ -96,7 +96,11 @@ public final class UserManager {
}
public static McMMOPlayer getPlayer(Player player) {
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
//Avoid Array Index out of bounds
if(player.hasMetadata(mcMMO.playerDataKey))
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
else
return null;
}
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {