Add to online player if they're online

This commit is contained in:
samczsun 2017-03-06 17:24:43 -05:00 committed by cnr
parent ca5b4386f3
commit d1993465a6
1 changed files with 16 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.MiniPlugin;
@ -13,9 +14,11 @@ import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.titles.commands.GiveTrackCommand;
import mineplex.core.titles.tracks.award.Bridges2017Track;
@ -121,7 +124,7 @@ public class TrackManager extends MiniPlugin
runAsync(() ->
{
_inventoryManager.addItemToInventoryForOffline(success ->
Callback<Boolean> successCallback = success ->
{
if (success)
{
@ -131,7 +134,18 @@ public class TrackManager extends MiniPlugin
{
UtilPlayer.message(caller, F.main(getName(), "Oops. Something has gone wrong while giving " + F.elem(player) + " the track " + F.elem(track) + "!"));
}
}, client.getAccountId(), "track." + track, 1);
};
Player playerObj = Bukkit.getPlayer(client.getUniqueId());
if (playerObj != null)
{
_inventoryManager.addItemToInventory(successCallback, playerObj, "track." + track, 1);
}
else
{
_inventoryManager.addItemToInventoryForOffline(successCallback, client.getAccountId(), "track." + track, 1);
}
});
});
}