[Core] Add MB Stats in gui, Add MB Achievement, Update stat gui layout, add ability to display combined stats

This commit is contained in:
Shaun Bennett 2015-05-12 17:14:50 -05:00
parent 26db4fa269
commit 53555a42cd
5 changed files with 106 additions and 83 deletions

View File

@ -191,6 +191,13 @@ public enum Achievement
new int[]{1}, new int[]{1},
AchievementCategory.DRAW_MY_THING), AchievementCategory.DRAW_MY_THING),
// Master Builders
MASTER_BUILDER_WINS("Master Builder", 1000,
new String[]{"Master Builders.Wins"},
new String[]{"Win 30 games of Master Builders"},
new int[]{30},
AchievementCategory.MASTER_BUILDERS),
//Castle Siege //Castle Siege
CASTLE_SIEGE_WINS("FOR THE KING!", 600, CASTLE_SIEGE_WINS("FOR THE KING!", 600,
new String[]{"Castle Siege.ForTheKing"}, new String[]{"Castle Siege.ForTheKing"},

View File

@ -12,136 +12,113 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.stats.PlayerStats; import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
/**
* Created by Shaun on 8/21/2014.
* Edited by Chris on 9/13/2059.
*/
public enum AchievementCategory public enum AchievementCategory
{ {
GLOBAL("Global", null, GLOBAL("Global", null,
new String[] { "GemsEarned", null, "GamesPlayed", "TimeInGame" }, new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME },
new String[] { "Gems Earned", null, "Games Played", "Time In Game" },
Material.EMERALD, 0, GameCategory.GLOBAL, null), Material.EMERALD, 0, GameCategory.GLOBAL, null),
//Survival //Survival
BRIDGES("The Bridges", null, BRIDGES("The Bridges", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit"), Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit"),
SURVIVAL_GAMES("Survival Games", null, SURVIVAL_GAMES("Survival Games", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, Material.DIAMOND_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
Material.IRON_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
MINE_STRIKE("MineStrike", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.TNT, 0, GameCategory.CLASSICS, null),
WIZARDS("Wizards", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
UHC("Ultra Hardcore", null, UHC("Ultra Hardcore", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"), Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
WIZARDS("Wizards", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
MINE_STRIKE("MineStrike", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.TNT, 0, GameCategory.CLASSICS, null),
//Classics //Classics
SMASH_MOBS("Super Smash Mobs", null, SMASH_MOBS("Super Smash Mobs", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit"), Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit"),
BLOCK_HUNT("Block Hunt", null, BLOCK_HUNT("Block Hunt", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.GRASS, 0, GameCategory.CLASSICS, null), Material.GRASS, 0, GameCategory.CLASSICS, null),
MASTER_BUILDERS("Master Builders", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
Material.WOOD, 0, GameCategory.CLASSICS, null),
DRAW_MY_THING("Draw My Thing", null, DRAW_MY_THING("Draw My Thing", null,
new String[] {"Wins", "Losses", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "GemsEarned"},
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, null), Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, null),
CASTLE_SIEGE("Castle Siege", null, CASTLE_SIEGE("Castle Siege", null,
new String[] {"Wins", "Losses", "Kills as Defenders", "Deaths as Defenders", "Kills as Undead", "Deaths as Undead", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"),
new String[] {"Wins", "Losses", "Kills as Defenders", "Deaths as Defenders", "Kills as Undead", "Deaths as Undead", "Gems Earned"}, new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED },
Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null), Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null),
//Champions //Champions
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"}, CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"), Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"),
//Arcade //Arcade
DRAGONS("Dragons", null, DRAGONS("Dragons", null,
new String[] {"Wins", "Losses", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Gems Earned"},
Material.ENDER_STONE, 0, GameCategory.ARCADE, null), Material.ENDER_STONE, 0, GameCategory.ARCADE, null),
DRAGON_ESCAPE("Dragon Escape", null, DRAGON_ESCAPE("Dragon Escape", null,
new String[] {"Wins", "Losses", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Gems Earned"},
Material.DRAGON_EGG, 0, GameCategory.ARCADE, null), Material.DRAGON_EGG, 0, GameCategory.ARCADE, null),
SHEEP_QUEST("Sheep Quest", null, SHEEP_QUEST("Sheep Quest", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.WOOL, 0, GameCategory.ARCADE, null), Material.WOOL, 0, GameCategory.ARCADE, null),
SNEAKY_ASSASSINS("Sneaky Assassins", null, SNEAKY_ASSASSINS("Sneaky Assassins", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.INK_SACK, 0, GameCategory.ARCADE, null), Material.INK_SACK, 0, GameCategory.ARCADE, null),
ONE_IN_THE_QUIVER("One in the Quiver", null, ONE_IN_THE_QUIVER("One in the Quiver", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.BOW, 0, GameCategory.ARCADE, null), Material.BOW, 0, GameCategory.ARCADE, null),
SUPER_PAINTBALL("Super Paintball", null, SUPER_PAINTBALL("Super Paintball", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.ENDER_PEARL, 0, GameCategory.ARCADE, null), Material.ENDER_PEARL, 0, GameCategory.ARCADE, null),
TURF_WARS("Turf Wars", null, TURF_WARS("Turf Wars", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.HARD_CLAY, 14, GameCategory.ARCADE, null), Material.HARD_CLAY, 14, GameCategory.ARCADE, null),
RUNNER("Runner", null, RUNNER("Runner", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null), Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null),
SPLEEF("Super Spleef", null, SPLEEF("Super Spleef", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.IRON_SPADE, 0, GameCategory.ARCADE, null), Material.IRON_SPADE, 0, GameCategory.ARCADE, null),
DEATH_TAG("Death Tag", null, DEATH_TAG("Death Tag", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.SKULL_ITEM, 0, GameCategory.ARCADE, null), Material.SKULL_ITEM, 0, GameCategory.ARCADE, null),
SNAKE("Snake", null, SNAKE("Snake", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.WOOL, 4, GameCategory.ARCADE, null), Material.WOOL, 4, GameCategory.ARCADE, null),
BACON_BRAWL("Bacon Brawl", null, BACON_BRAWL("Bacon Brawl", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.PORK, 0, GameCategory.ARCADE, null), Material.PORK, 0, GameCategory.ARCADE, null),
MICRO_BATTLE("Micro Battle", null, MICRO_BATTLE("Micro Battle", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.LAVA, 0, GameCategory.ARCADE, null), Material.LAVA, 0, GameCategory.ARCADE, null),
; ;
@ -149,14 +126,13 @@ public enum AchievementCategory
private String _name; private String _name;
private String[] _statsToPull; private String[] _statsToPull;
private String[] _statsToDisplay; private StatDisplay[] _statDisplays;
private String[] _friendlyStatNames;
private Material _icon; private Material _icon;
private GameCategory _gameCategory; private GameCategory _gameCategory;
private byte _iconData; private byte _iconData;
private String _kitReward; private String _kitReward;
AchievementCategory(String name, String[] statsToPull, String[] statsToDisplay, String[] friendlyStatNames, Material icon, int iconData, GameCategory gameCategory, String kitReward) AchievementCategory(String name, String[] statsToPull, StatDisplay[] statDisplays, Material icon, int iconData, GameCategory gameCategory, String kitReward)
{ {
_name = name; _name = name;
@ -164,9 +140,7 @@ public enum AchievementCategory
_statsToPull = statsToPull; _statsToPull = statsToPull;
else else
_statsToPull = new String[] {name}; _statsToPull = new String[] {name};
_statDisplays = statDisplays;
_statsToDisplay = statsToDisplay;
_friendlyStatNames = friendlyStatNames;
_icon = icon; _icon = icon;
_iconData = (byte)iconData; _iconData = (byte)iconData;
_gameCategory = gameCategory; _gameCategory = gameCategory;
@ -193,9 +167,9 @@ public enum AchievementCategory
return _statsToPull; return _statsToPull;
} }
public String[] getStatsToDisplay() public StatDisplay[] getStatsToDisplay()
{ {
return _statsToDisplay; return _statDisplays;
} }
public byte getIconData() public byte getIconData()
@ -208,11 +182,6 @@ public enum AchievementCategory
return _gameCategory; return _gameCategory;
} }
public String[] getFriendlyStatNames()
{
return _friendlyStatNames;
}
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, Player target)
{ {
addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, target); addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, target);
@ -221,29 +190,32 @@ public enum AchievementCategory
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, Player target)
{ {
PlayerStats stats = statsManager.Get(target); PlayerStats stats = statsManager.Get(target);
for (int i = 0; i < _statsToDisplay.length && i < max; i++) for (int i = 0; i < _statDisplays.length && i < max; i++)
{ {
// If the stat is null then just display a blank line instead // If the stat is null then just display a blank line instead
if (_statsToDisplay[i] == null || _friendlyStatNames[i] == null) if (_statDisplays[i] == null)
{ {
lore.add(" "); lore.add(" ");
continue; continue;
} }
String displayName = _statDisplays[i].getDisplayName();
// Skip showing Losses, Kills, Deaths for other players // Skip showing Losses, Kills, Deaths for other players
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"))) 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")))
continue; continue;
int statNumber = 0; int statNumber = 0;
for (String statToPull : _statsToPull) for (String statToPull : _statsToPull)
statNumber += stats.getStat(statToPull + "." + _statsToDisplay[i]); for (String statName : _statDisplays[i].getStats())
statNumber += stats.getStat(statToPull + "." + statName);
String statString = C.cWhite + statNumber; String statString = C.cWhite + statNumber;
// Need to display special for time // Need to display special for time
if (_statsToDisplay[i].equalsIgnoreCase("TimeInGame")) if (displayName.equalsIgnoreCase("Time In Game"))
statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT); statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT);
lore.add(C.cYellow + _friendlyStatNames[i] + ": " + statString); lore.add(C.cYellow + displayName + ": " + statString);
} }
} }

View File

@ -0,0 +1,44 @@
package mineplex.core.achievement;
/**
* The purpose of extracting stats to this class is so we can display stats that are a combination
* of different stat values. For example, since we don't have a specific stat for games played of a game,
* we can use this class to display the stat "Games Played" that sums up "Wins" and "Losses"
* See: StatDisplay.GAMES_PLAYED_GAME
*/
public class StatDisplay
{
public String _displayName;
public String[] _stats;
public StatDisplay(String stat)
{
_displayName = stat;
_stats = new String[] { stat };
}
public StatDisplay(String displayName, String... stats)
{
_displayName = displayName;
_stats = stats;
}
public String getDisplayName()
{
return _displayName;
}
public String[] getStats()
{
return _stats;
}
public static final StatDisplay WINS = new StatDisplay("Wins");
public static final StatDisplay LOSSES = new StatDisplay("Losses");
public static final StatDisplay KILLS = new StatDisplay("Kills");
public static final StatDisplay DEATHS = new StatDisplay("Deaths");
public static final StatDisplay GEMS_EARNED = new StatDisplay("Gems Earned", "GemsEarned");
public static final StatDisplay TIME_IN_GAME = new StatDisplay("Time In Game", "TimeInGame");
public static final StatDisplay GAMES_PLAYED_GAME = new StatDisplay("Games Played", "Wins", "Losses");
}

View File

@ -45,11 +45,11 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
{ {
ArrayList<Integer> pageLayout = new ItemLayout( ArrayList<Integer> pageLayout = new ItemLayout(
"XXXXOXXXX", "XXXXOXXXX",
"XOXOXOXOX",
"XXXXXXXXX", "XXXXXXXXX",
"OXOXOXOXO", "XOXOXOXOX",
"XXXXXXXXX", "XXXXXXXXX",
"OXOXOXOXO", "XOXOXOXOX").getItemSlots();
"XXXXOXXXX").getItemSlots();
int listSlot = 0; int listSlot = 0;
for (AchievementCategory category : AchievementCategory.values()) for (AchievementCategory category : AchievementCategory.values())

View File

@ -39,7 +39,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{ {
super(plugin, quickShop, clientManager, donationManager, name, player, 56); super(plugin, quickShop, clientManager, donationManager, name, player, 47);
createSuperSmashCycle(); createSuperSmashCycle();
createMinigameCycle(); createMinigameCycle();