Add gamesplayed and timeingame to gui

This commit is contained in:
Shaun Bennett 2014-10-02 19:48:25 -05:00
parent 9b2a2cbbd6
commit 07576a2b12
3 changed files with 38 additions and 13 deletions

View File

@ -1,8 +1,6 @@
package mineplex.core.achievement;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
/**
* Created by Shaun on 8/21/2014.
@ -11,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
public enum AchievementCategory
{
GLOBAL("Global", null,
new String[] { "GemsEarned" },
new String[] { "Gems Earned" },
new String[] { "GemsEarned", null, "GamesPlayed", "TimeInGame" },
new String[] { "Gems Earned", null, "Games Played", "Time In Game" },
Material.EMERALD, 0, GameCategory.GLOBAL),
//Survival

View File

@ -15,7 +15,9 @@ import mineplex.core.achievement.AchievementManager;
import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.achievement.ui.button.ArcadeButton;
import mineplex.core.achievement.ui.button.CategoryButton;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
@ -55,7 +57,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
addStats(category, lore, 2);
addStats(category, lore, category == AchievementCategory.GLOBAL ? 5 : 2);
lore.add(" ");
addAchievements(category, lore, 9);
lore.add(" ");
@ -88,17 +90,27 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
PlayerStats stats = _statsManager.Get(_target);
for (int i = 0; i < statsToDisplay.length && i < max; i++)
{
// If the stat is null then just display a blank line instead
if (statsToDisplay[i] == null || friendlyStatNames[i] == null)
{
lore.add(" ");
continue;
}
// Skip showing Losses, Kills, Deaths for other players
if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths")))
if (!ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR) && !Player.equals(_target) && (statsToDisplay[i].contains("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths") || statsToDisplay[i].equals("Time In Game") || statsToDisplay.equals("Games Played")))
continue;
String statName = statsToDisplay[i];
int statNumber = 0;
for (String statToPull : category.getStatsToPull())
statNumber += stats.getStat(statToPull + "." + statName);
statNumber += stats.getStat(statToPull + "." + statsToDisplay[i]);
String statString = C.cWhite + statNumber;
// Need to display special for time
if (statsToDisplay[i].equalsIgnoreCase("TimeInGame"))
statString = C.cWhite + UtilTime.convertString(statNumber, 0, UtilTime.TimeUnit.SECONDS);
lore.add(C.cYellow + friendlyStatNames[i] + ": " + C.cWhite + statNumber);
lore.add(C.cYellow + friendlyStatNames[i] + ": " + statString);
}
}

View File

@ -16,7 +16,9 @@ import mineplex.core.achievement.AchievementCategory;
import mineplex.core.achievement.AchievementData;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
@ -162,15 +164,28 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
String[] friendlyStatNames = _category.getFriendlyStatNames();
for (int i = 0; i < statsToDisplay.length; i++)
{
// If the stat is null then just display a blank line instead
if (statsToDisplay[i] == null || friendlyStatNames[i] == null)
{
lore.add(" ");
continue;
}
// Skip showing Losses, Kills, Deaths for other players
if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths")))
if (!ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR) && !Player.equals(_target) && (statsToDisplay[i].contains("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths") || statsToDisplay[i].equals("Time In Game") || statsToDisplay.equals("Games Played")))
continue;
int statNumber = 0;
for (String statToPull : _category.getStatsToPull())
statNumber += stats.getStat(statToPull + "." + statsToDisplay[i]);
lore.add(C.cYellow + friendlyStatNames[i] + ": " + C.cWhite + statNumber);
String statString = C.cWhite + statNumber;
// Need to display special for time
if (statsToDisplay[i].equalsIgnoreCase("TimeInGame"))
statString = UtilTime.convertString(statNumber, 0, UtilTime.TimeUnit.SECONDS);
lore.add(C.cYellow + friendlyStatNames[i] + ": " + statString);
}
ItemStack item = new ItemStack(material);