Add offline stat checking
This commit is contained in:
parent
225583a13d
commit
b1b9900c9e
@ -235,14 +235,13 @@ public enum AchievementCategory
|
||||
return _gameCategory;
|
||||
}
|
||||
|
||||
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, Player player, Player target)
|
||||
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, target);
|
||||
addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, targetName, targetStats);
|
||||
}
|
||||
|
||||
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, int max, Player player, Player target)
|
||||
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, int max, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
PlayerStats stats = statsManager.Get(target);
|
||||
for (int i = 0; i < _statDisplays.length && i < max; i++)
|
||||
{
|
||||
// If the stat is null then just display a blank line instead
|
||||
@ -260,7 +259,7 @@ public enum AchievementCategory
|
||||
String displayName = _statDisplays[i].getDisplayName();
|
||||
|
||||
// Skip showing Losses, Kills, Deaths for other players
|
||||
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
continue;
|
||||
|
||||
double statNumber = 0;
|
||||
@ -271,7 +270,7 @@ public enum AchievementCategory
|
||||
if (_statDisplays[i].isFullStat())
|
||||
{
|
||||
for (String statName : _statDisplays[i].getStats())
|
||||
statNumber += stats.getStat(statName);
|
||||
statNumber += targetStats.getStat(statName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -283,17 +282,17 @@ public enum AchievementCategory
|
||||
{
|
||||
if(statNumber == 0)
|
||||
{
|
||||
statNumber = stats.getStat(statToPull + "." + statName);
|
||||
statNumber = targetStats.getStat(statToPull + "." + statName);
|
||||
continue;
|
||||
}
|
||||
double stat = stats.getStat(statToPull + "." + statName);
|
||||
double stat = targetStats.getStat(statToPull + "." + statName);
|
||||
if(stat == 0)
|
||||
statNumber = statNumber / 1;
|
||||
else
|
||||
statNumber = (double) statNumber / stat;
|
||||
}
|
||||
else
|
||||
statNumber += stats.getStat(statToPull + "." + statName);
|
||||
statNumber += targetStats.getStat(statToPull + "." + statName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.achievement;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -22,6 +23,7 @@ import java.util.UUID;
|
||||
|
||||
public class AchievementManager extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private IncognitoManager _incognitoManager;
|
||||
private StatsManager _statsManager;
|
||||
private EloManager _eloManager;
|
||||
@ -41,6 +43,7 @@ public class AchievementManager extends MiniPlugin
|
||||
_incognitoManager = incognitoManager;
|
||||
_statsManager = statsManager;
|
||||
_eloManager = eloManager;
|
||||
_clientManager = clientManager;
|
||||
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
|
||||
}
|
||||
|
||||
@ -50,17 +53,22 @@ public class AchievementManager extends MiniPlugin
|
||||
}
|
||||
|
||||
public AchievementData get(UUID playerUUID, Achievement type)
|
||||
{
|
||||
return get(_statsManager.Get(playerUUID), type);
|
||||
}
|
||||
|
||||
public AchievementData get(PlayerStats stats, Achievement type)
|
||||
{
|
||||
int exp = 0;
|
||||
|
||||
for (String stat : type.getStats())
|
||||
{
|
||||
exp += _statsManager.Get(playerUUID).getStat(stat);
|
||||
exp += stats.getStat(stat);
|
||||
}
|
||||
|
||||
return type.getLevelData(exp);
|
||||
}
|
||||
|
||||
|
||||
public EloManager getEloManager()
|
||||
{
|
||||
return _eloManager;
|
||||
@ -127,12 +135,17 @@ public class AchievementManager extends MiniPlugin
|
||||
|
||||
public void openShop(Player player)
|
||||
{
|
||||
_shop.attemptShopOpen(player);
|
||||
openShop(player, player);
|
||||
}
|
||||
|
||||
public void openShop(Player player, Player target)
|
||||
{
|
||||
_shop.attemptShopOpen(player, target);
|
||||
openShop(player, target.getName(), _statsManager.Get(target));
|
||||
}
|
||||
|
||||
public void openShop(Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
_shop.attemptShopOpen(player, targetName, targetStats);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -212,7 +225,12 @@ public class AchievementManager extends MiniPlugin
|
||||
{
|
||||
return Achievement.getExperienceString(getMineplexLevelNumber(sender, rank)) + " " + ChatColor.RESET;
|
||||
}
|
||||
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public void setShopEnabled(boolean var)
|
||||
{
|
||||
_shopEnabled = var;
|
||||
@ -222,4 +240,9 @@ public class AchievementManager extends MiniPlugin
|
||||
{
|
||||
return _incognitoManager;
|
||||
}
|
||||
|
||||
public StatsManager getStatsManager()
|
||||
{
|
||||
return _statsManager;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.achievement.command;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
@ -9,6 +10,8 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class StatsCommand extends CommandBase<AchievementManager>
|
||||
{
|
||||
public StatsCommand(AchievementManager plugin)
|
||||
@ -29,6 +32,7 @@ public class StatsCommand extends CommandBase<AchievementManager>
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
if (Plugin.getClientManager().hasRank(caller, Rank.MODERATOR)) attemptOffline(caller, args);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -43,4 +47,47 @@ public class StatsCommand extends CommandBase<AchievementManager>
|
||||
Plugin.openShop(caller, target);
|
||||
}
|
||||
}
|
||||
|
||||
private void attemptOffline(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
Plugin.openShop(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", "Attempting to look up offline stats..."));
|
||||
final String playerName = args[0];
|
||||
|
||||
Plugin.runAsync(() -> {
|
||||
try
|
||||
{
|
||||
PlayerStats stats = Plugin.getStatsManager().getOfflinePlayerStats(playerName);
|
||||
|
||||
if (stats == null)
|
||||
{
|
||||
Plugin.runSync(() -> offlinePlayerNotFound(caller, playerName));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.runSync(() -> openShop(caller, playerName, stats));
|
||||
}
|
||||
} catch (SQLException e)
|
||||
{
|
||||
Plugin.runSync(() -> UtilPlayer.message(caller, F.main("Stats", "There was an error trying to look up offline player " + F.elem(playerName))));
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void offlinePlayerNotFound(Player caller, String searchName)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", "Offline Player " + F.elem(searchName) + " not found."));
|
||||
}
|
||||
|
||||
private void openShop(Player caller, String searchName, PlayerStats playerStats)
|
||||
{
|
||||
Plugin.openShop(caller, searchName, playerStats);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.achievement.ui;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -26,15 +27,15 @@ public class AchievementShop extends ShopBase<AchievementManager>
|
||||
@Override
|
||||
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return BuildPagesFor(player, player);
|
||||
return BuildPagesFor(player, player.getName(), getPlugin().getStatsManager().Get(player));
|
||||
}
|
||||
|
||||
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> BuildPagesFor(Player player, Player target)
|
||||
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> BuildPagesFor(Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
return new AchievementMainPage(getPlugin(), _statsManager, this, getClientManager(), getDonationManager(), target.getName() + "'s Stats", player, target);
|
||||
return new AchievementMainPage(getPlugin(), _statsManager, this, getClientManager(), getDonationManager(), targetName + "'s Stats", player, targetName, targetStats);
|
||||
}
|
||||
|
||||
public boolean attemptShopOpen(Player player, Player target)
|
||||
public boolean attemptShopOpen(Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
if (!getOpenedShop().contains(player.getName()))
|
||||
{
|
||||
@ -46,7 +47,7 @@ public class AchievementShop extends ShopBase<AchievementManager>
|
||||
openShopForPlayer(player);
|
||||
if (!getPlayerPageMap().containsKey(player.getName()))
|
||||
{
|
||||
getPlayerPageMap().put(player.getName(), BuildPagesFor(player, target));
|
||||
getPlayerPageMap().put(player.getName(), BuildPagesFor(player, targetName, targetStats));
|
||||
}
|
||||
|
||||
openPageForPlayer(player, getOpeningPageForPlayer(player));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.achievement.ui.button;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -19,22 +20,26 @@ public class ArcadeButton implements IButton
|
||||
private StatsManager _statsManager;
|
||||
private DonationManager _donationManager;
|
||||
private CoreClientManager _clientManager;
|
||||
private Player _target;
|
||||
|
||||
public ArcadeButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, DonationManager donationManager, CoreClientManager clientManager, Player target)
|
||||
private String _targetName;
|
||||
private PlayerStats _targetStats;
|
||||
|
||||
public ArcadeButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, DonationManager donationManager, CoreClientManager clientManager, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
_shop = shop;
|
||||
_achievementManager = achievementManager;
|
||||
_statsManager = statsManager;
|
||||
_donationManager = donationManager;
|
||||
_clientManager = clientManager;
|
||||
_target = target;
|
||||
|
||||
_targetName = targetName;
|
||||
_targetStats = targetStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_shop.openPageForPlayer(player, new ArcadeMainPage(_achievementManager, _statsManager, _shop, _clientManager, _donationManager, "Arcade Games", player, _target));
|
||||
_shop.openPageForPlayer(player, new ArcadeMainPage(_achievementManager, _statsManager, _shop, _clientManager, _donationManager, "Arcade Games", player, _targetName, _targetStats));
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.achievement.ui.button;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -24,9 +25,11 @@ public class CategoryButton implements IButton
|
||||
private StatsManager _statsManager;
|
||||
private DonationManager _donationManager;
|
||||
private CoreClientManager _clientManager;
|
||||
private Player _target;
|
||||
|
||||
public CategoryButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, AchievementCategory category, DonationManager donationManager, CoreClientManager clientManager, Player target)
|
||||
private String _targetName;
|
||||
private PlayerStats _targetStats;
|
||||
|
||||
public CategoryButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, AchievementCategory category, DonationManager donationManager, CoreClientManager clientManager, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
_category = category;
|
||||
_shop = shop;
|
||||
@ -34,13 +37,14 @@ public class CategoryButton implements IButton
|
||||
_statsManager = statsManager;
|
||||
_donationManager = donationManager;
|
||||
_clientManager = clientManager;
|
||||
_target = target;
|
||||
_targetName = targetName;
|
||||
_targetStats = targetStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_shop.openPageForPlayer(player, new AchievementPage(_achievementManager, _statsManager, _category, _shop, _clientManager, _donationManager, player, _target));
|
||||
_shop.openPageForPlayer(player, new AchievementPage(_achievementManager, _statsManager, _category, _shop, _clientManager, _donationManager, player, _targetName, _targetStats));
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.achievement.ui.page;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -24,19 +25,22 @@ import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class AchievementMainPage extends ShopPageBase<AchievementManager, AchievementShop>
|
||||
{
|
||||
protected Player _target;
|
||||
protected StatsManager _statsManager;
|
||||
|
||||
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Player target)
|
||||
protected String _targetName;
|
||||
protected PlayerStats _targetStats;
|
||||
|
||||
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
this(plugin, statsManager, shop, clientManager, donationManager, name, 9 * 4, player, target);
|
||||
this(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 4, targetName, targetStats);
|
||||
}
|
||||
|
||||
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, int size, Player player, Player target)
|
||||
|
||||
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, int size, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player, size);
|
||||
|
||||
_target = target;
|
||||
_targetName = targetName;
|
||||
_targetStats = targetStats;
|
||||
_statsManager = statsManager;
|
||||
|
||||
buildPage();
|
||||
@ -58,12 +62,12 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
continue;
|
||||
|
||||
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(),
|
||||
getClientManager(), _target);
|
||||
getClientManager(), _targetName, _targetStats);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 10 : 2,
|
||||
getPlayer(), _target);
|
||||
getPlayer(), _targetName, _targetStats);
|
||||
lore.add(" ");
|
||||
addAchievements(category, lore, 9);
|
||||
lore.add(ChatColor.RESET + "Click for more details!");
|
||||
@ -78,7 +82,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
|
||||
protected void addArcadeButton(int slot)
|
||||
{
|
||||
ArcadeButton button = new ArcadeButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _target);
|
||||
ArcadeButton button = new ArcadeButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _targetName, _targetStats);
|
||||
ShopItem shopItem = new ShopItem(Material.BOW, (byte) 0, C.Bold + "Arcade Games", new String[] {" ", ChatColor.RESET + "Click for more!"}, 1, false, false);
|
||||
|
||||
addButton(slot, shopItem, button);
|
||||
@ -96,7 +100,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
if (achievement.getMaxLevel() > 1)
|
||||
continue;
|
||||
|
||||
AchievementData data = getPlugin().get(_target, achievement);
|
||||
AchievementData data = getPlugin().get(_targetStats, achievement);
|
||||
boolean finished = data.getLevel() >= achievement.getMaxLevel();
|
||||
|
||||
lore.add((finished ? C.cGreen : C.cRed) + achievement.getName());
|
||||
|
@ -10,12 +10,14 @@ import mineplex.core.achievement.AchievementData;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.elo.EloManager.EloDivision;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -33,17 +35,21 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
private AchievementCategory _category;
|
||||
private StatsManager _statsManager;
|
||||
private EloManager _eloManager;
|
||||
private Player _target;
|
||||
|
||||
public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Player target)
|
||||
private String _targetName;
|
||||
private PlayerStats _targetStats;
|
||||
|
||||
public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, category.getFriendlyName(), player);
|
||||
|
||||
_statsManager = statsManager;
|
||||
_category = category;
|
||||
_target = target;
|
||||
_eloManager = plugin.getEloManager();
|
||||
|
||||
_targetName = targetName;
|
||||
_targetStats = targetStats;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@ -60,7 +66,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
List<Achievement> achievements = getAchievements();
|
||||
for (Achievement achievement : achievements)
|
||||
{
|
||||
AchievementData data = getPlugin().get(_target, achievement);
|
||||
AchievementData data = getPlugin().get(_targetStats, achievement);
|
||||
boolean singleLevel = achievement.isSingleLevel();
|
||||
boolean hasUnlocked = data.getLevel() >= achievement.getMaxLevel();
|
||||
|
||||
@ -117,7 +123,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
{
|
||||
String itemName = ChatColor.RESET + _category.getFriendlyName() + " Master Achievement";
|
||||
masterAchievementLore.add(" ");
|
||||
if (getPlayer().equals(_target))
|
||||
if (getPlayer().getName().equalsIgnoreCase(_targetName))
|
||||
{
|
||||
if (_category.getReward() != null)
|
||||
masterAchievementLore.add(C.cYellow + C.Bold + "Reward: " + ChatColor.RESET + _category.getReward());
|
||||
@ -141,9 +147,9 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
{
|
||||
AchievementMainPage page;
|
||||
if (_category.getGameCategory() == AchievementCategory.GameCategory.ARCADE)
|
||||
page = new ArcadeMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), "Arcade Games", player, _target);
|
||||
page = new ArcadeMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), "Arcade Games", player, _targetName, _targetStats);
|
||||
else
|
||||
page = new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _target.getName() + "'s Stats", player, _target);
|
||||
page = new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _targetName + "'s Stats", player, _targetName, _targetStats);
|
||||
;
|
||||
|
||||
getShop().openPageForPlayer(getPlayer(), page);
|
||||
@ -162,7 +168,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
String itemName = C.Bold + _category.getFriendlyName() + " Stats";
|
||||
List<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
_category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _target);
|
||||
_category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _targetName, _targetStats);
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@ -175,27 +181,31 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
|
||||
private void addDivisionDisplay()
|
||||
{
|
||||
if (_category.getFriendlyName().startsWith("Global"))
|
||||
return;
|
||||
if (!_category.DisplayDivision || _category.GameId.length < 1)
|
||||
return;
|
||||
if (_category.GameId.length > 1)
|
||||
Player target = UtilPlayer.searchExact(_targetName);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
for (int i = 0; i < _category.GameId.length; i++)
|
||||
if (_category.getFriendlyName().startsWith("Global"))
|
||||
return;
|
||||
if (!_category.DisplayDivision || _category.GameId.length < 1)
|
||||
return;
|
||||
if (_category.GameId.length > 1)
|
||||
{
|
||||
int id = _category.GameId[i];
|
||||
int elo = _eloManager.getElo(_target, id);
|
||||
for (int i = 0; i < _category.GameId.length; i++)
|
||||
{
|
||||
int id = _category.GameId[i];
|
||||
int elo = _eloManager.getElo(target, id);
|
||||
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
|
||||
setItem(44 + i + 1, disp);
|
||||
}
|
||||
} else
|
||||
{
|
||||
int id = _category.GameId[0];
|
||||
int elo = _eloManager.getElo(target, id);
|
||||
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
|
||||
setItem(44 + i + 1, disp);
|
||||
setItem(49, disp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = _category.GameId[0];
|
||||
int elo = _eloManager.getElo(_target, id);
|
||||
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
|
||||
setItem(49, disp);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Achievement> getAchievements()
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.achievement.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -21,11 +22,9 @@ import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class ArcadeMainPage extends AchievementMainPage
|
||||
{
|
||||
public ArcadeMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Player target)
|
||||
public ArcadeMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
super(plugin, statsManager, shop, clientManager, donationManager, name, 9 * 5, player, target);
|
||||
|
||||
|
||||
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 5, targetName, targetStats);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,11 +37,11 @@ public class ArcadeMainPage extends AchievementMainPage
|
||||
if (category.getGameCategory() != AchievementCategory.GameCategory.ARCADE)
|
||||
continue;
|
||||
|
||||
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _target);
|
||||
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _targetName, _targetStats);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _target);
|
||||
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _targetName, _targetStats);
|
||||
lore.add(" ");
|
||||
addAchievements(category, lore, 9);
|
||||
lore.add(" ");
|
||||
@ -63,7 +62,7 @@ public class ArcadeMainPage extends AchievementMainPage
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
getShop().openPageForPlayer(getPlayer(), new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _target.getName() + "'s Stats", player, _target));
|
||||
getShop().openPageForPlayer(getPlayer(), new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _targetName + "'s Stats", player, _targetName, _targetStats));
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user