Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
7669998ad3
@ -18,6 +18,7 @@
|
|||||||
<processorPath useClasspath="true" />
|
<processorPath useClasspath="true" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel target="1.7" />
|
||||||
</component>
|
</component>
|
||||||
<component name="JavacSettings">
|
<component name="JavacSettings">
|
||||||
<option name="GENERATE_NO_WARNINGS" value="true" />
|
<option name="GENERATE_NO_WARNINGS" value="true" />
|
||||||
|
@ -5,33 +5,39 @@ public enum Achievement
|
|||||||
GLOBAL_GEM_HUNTER("Gem Hunter",
|
GLOBAL_GEM_HUNTER("Gem Hunter",
|
||||||
new String[] {"Global.GemsEarned"},
|
new String[] {"Global.GemsEarned"},
|
||||||
new String[] {"+1 for every Gem earned in any game."},
|
new String[] {"+1 for every Gem earned in any game."},
|
||||||
new int[] {10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000}),
|
new int[] {10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000},
|
||||||
|
AchievementCategory.GLOBAL),
|
||||||
|
|
||||||
//Survival Games
|
//Survival Games
|
||||||
SURVIVAL_GAMES_WINS("Katniss Everdeen",
|
SURVIVAL_GAMES_WINS("Katniss Everdeen",
|
||||||
new String[] {"Survival Games.Wins"},
|
new String[] {"Survival Games.Wins"},
|
||||||
new String[] {"Win 50 games of Survival Games"},
|
new String[] {"Win 50 games of Survival Games"},
|
||||||
new int[] {50}),
|
new int[] {50},
|
||||||
|
AchievementCategory.SURVIVAL_GAMES),
|
||||||
|
|
||||||
SURVIVAL_GAMES_NUDIST("Nudist",
|
SURVIVAL_GAMES_NUDIST("Nudist",
|
||||||
new String[] {"Survival Games.NoArmor"},
|
new String[] {"Survival Games.NoArmor"},
|
||||||
new String[] {"Win a game without wearing any armor"},
|
new String[] {"Win a game without wearing any armor"},
|
||||||
new int[] {1}),
|
new int[] {1},
|
||||||
|
AchievementCategory.SURVIVAL_GAMES),
|
||||||
|
|
||||||
SURVIVAL_GAMES_BLOODLUST("Bloodlust",
|
SURVIVAL_GAMES_BLOODLUST("Bloodlust",
|
||||||
new String[] {"Survival Games.Bloodlust"},
|
new String[] {"Survival Games.Bloodlust"},
|
||||||
new String[] {"Kill 3 other players in the first minute"},
|
new String[] {"Kill 3 other players in the first minute"},
|
||||||
new int[] {1}),
|
new int[] {1},
|
||||||
|
AchievementCategory.SURVIVAL_GAMES),
|
||||||
|
|
||||||
SURVIVAL_GAMES_LOOT("Loot Hoarder",
|
SURVIVAL_GAMES_LOOT("Loot Hoarder",
|
||||||
new String[] {"Survival Games.SupplyDropsOpened"},
|
new String[] {"Survival Games.SupplyDropsOpened"},
|
||||||
new String[] {"Be the first to open 50 Supply Drops"},
|
new String[] {"Be the first to open 50 Supply Drops"},
|
||||||
new int[] {50}),
|
new int[] {50},
|
||||||
|
AchievementCategory.SURVIVAL_GAMES),
|
||||||
|
|
||||||
SURVIVAL_GAMES_SKELETONS("Skeletal Army",
|
SURVIVAL_GAMES_SKELETONS("Skeletal Army",
|
||||||
new String[] {"Survival Games.Skeletons"},
|
new String[] {"Survival Games.Skeletons"},
|
||||||
new String[] {"Have 5 Necromanced Skeletons alive"},
|
new String[] {"Have 5 Necromanced Skeletons alive"},
|
||||||
new int[] {1});
|
new int[] {1},
|
||||||
|
AchievementCategory.SURVIVAL_GAMES);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -45,13 +51,15 @@ public enum Achievement
|
|||||||
private String[] _desc;
|
private String[] _desc;
|
||||||
private String[] _stats;
|
private String[] _stats;
|
||||||
private int[] _levels;
|
private int[] _levels;
|
||||||
|
private AchievementCategory _category;
|
||||||
|
|
||||||
Achievement(String name, String[] stats, String[] desc, int[] levels)
|
Achievement(String name, String[] stats, String[] desc, int[] levels, AchievementCategory category)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_desc = desc;
|
_desc = desc;
|
||||||
_stats = stats;
|
_stats = stats;
|
||||||
_levels = levels;
|
_levels = levels;
|
||||||
|
_category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
@ -83,8 +91,18 @@ public enum Achievement
|
|||||||
{
|
{
|
||||||
return _levels[0] > 1;
|
return _levels[0] > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSingleLevel()
|
||||||
|
{
|
||||||
|
return _levels.length == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AchievementCategory getCategory()
|
||||||
|
{
|
||||||
|
return _category;
|
||||||
|
}
|
||||||
|
|
||||||
public AchivementData getLevelData(int exp)
|
public AchievementData getLevelData(int exp)
|
||||||
{
|
{
|
||||||
for (int i=0 ; i<_levels.length ; i++)
|
for (int i=0 ; i<_levels.length ; i++)
|
||||||
{
|
{
|
||||||
@ -97,9 +115,9 @@ public enum Achievement
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AchivementData(i, exp, req);
|
return new AchievementData(i, exp, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AchivementData(getMaxLevel(), -1, -1);
|
return new AchievementData(getMaxLevel(), -1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package mineplex.core.achievement;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/21/2014.
|
||||||
|
*/
|
||||||
|
public enum AchievementCategory
|
||||||
|
{
|
||||||
|
GLOBAL("Global",
|
||||||
|
new String[] { "GemsEarned" },
|
||||||
|
Material.BED),
|
||||||
|
|
||||||
|
BRIDGES("The Bridges",
|
||||||
|
new String[] {"Wins", "Losses", "GemsEarned"},
|
||||||
|
Material.DIAMOND),
|
||||||
|
|
||||||
|
SURVIVAL_GAMES("Survival Games",
|
||||||
|
new String[] { "Wins", "Losses", "GemsEarned" },
|
||||||
|
Material.APPLE),
|
||||||
|
|
||||||
|
BACON_BRAWL("Bacon Brawl",
|
||||||
|
new String[] {"Wins", "Losses", "GemsEarned"},
|
||||||
|
Material.PORK),
|
||||||
|
|
||||||
|
BLOCK_HUNT("Block Hunt",
|
||||||
|
new String[] {"Wins", "Losses", "GemsEarned"},
|
||||||
|
Material.DIRT);;
|
||||||
|
|
||||||
|
private String _name;
|
||||||
|
private String[] _statsToDisplay;
|
||||||
|
private Material _icon;
|
||||||
|
|
||||||
|
AchievementCategory(String name, String[] statsToDisplay, Material icon)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
_statsToDisplay = statsToDisplay;
|
||||||
|
_icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFriendlyName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getIcon()
|
||||||
|
{
|
||||||
|
return _icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getStatsToDisplay()
|
||||||
|
{
|
||||||
|
return _statsToDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,14 +1,12 @@
|
|||||||
package mineplex.core.achievement;
|
package mineplex.core.achievement;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
public class AchievementData
|
||||||
|
|
||||||
public class AchivementData
|
|
||||||
{
|
{
|
||||||
private int _level;
|
private int _level;
|
||||||
private int _expRemainder;
|
private int _expRemainder;
|
||||||
private int _expNextLevel;
|
private int _expNextLevel;
|
||||||
|
|
||||||
public AchivementData(int level, int expRemainder, int expNextLevel)
|
public AchievementData(int level, int expRemainder, int expNextLevel)
|
||||||
{
|
{
|
||||||
_level = level;
|
_level = level;
|
||||||
_expRemainder = expRemainder;
|
_expRemainder = expRemainder;
|
@ -1,52 +1,69 @@
|
|||||||
package mineplex.core.achievement;
|
package mineplex.core.achievement;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.command.StatsCommand;
|
||||||
|
import mineplex.core.achievement.ui.AchievementShop;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilGear;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.stats.event.StatChangeEvent;
|
import mineplex.core.stats.event.StatChangeEvent;
|
||||||
|
|
||||||
public class AchievementManager extends MiniPlugin
|
public class AchievementManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
private StatsManager _statsManager;
|
private StatsManager _statsManager;
|
||||||
|
|
||||||
|
private AchievementShop _shop;
|
||||||
|
private int _interfaceSlot = 7;
|
||||||
|
private boolean _giveInterfaceItem = false;
|
||||||
|
|
||||||
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
|
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
|
||||||
|
|
||||||
public AchievementManager(StatsManager statsManager)
|
public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager)
|
||||||
{
|
{
|
||||||
super("Achievement Manager", statsManager.GetPlugin());
|
super("Achievement Manager", statsManager.GetPlugin());
|
||||||
|
|
||||||
_statsManager = statsManager;
|
_statsManager = statsManager;
|
||||||
|
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AchivementData get(Player player, Achievement type)
|
public AchievementData get(Player player, Achievement type)
|
||||||
{
|
{
|
||||||
return get(player.getName(), type);
|
return get(player.getName(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AchivementData get(String playerName, Achievement type)
|
public AchievementData get(String playerName, Achievement type)
|
||||||
{
|
{
|
||||||
int exp = 0;
|
int exp = 0;
|
||||||
|
|
||||||
for (String stat : type.getStats())
|
for (String stat : type.getStats())
|
||||||
{
|
{
|
||||||
exp += _statsManager.Get(playerName).getStat(stat);
|
exp += _statsManager.Get(playerName).getStat(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return type.getLevelData(exp);
|
return type.getLevelData(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void informLevelUp(StatChangeEvent event)
|
public void informLevelUp(StatChangeEvent event)
|
||||||
{
|
{
|
||||||
Player player = UtilPlayer.searchExact(event.getPlayerName());
|
Player player = UtilPlayer.searchExact(event.getPlayerName());
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Achievement type : Achievement.values())
|
for (Achievement type : Achievement.values())
|
||||||
{
|
{
|
||||||
for (String stat : type.getStats())
|
for (String stat : type.getStats())
|
||||||
@ -55,7 +72,7 @@ public class AchievementManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (!_log.containsKey(player.getName()))
|
if (!_log.containsKey(player.getName()))
|
||||||
_log.put(player.getName(), new NautHashMap<Achievement, AchievementLog>());
|
_log.put(player.getName(), new NautHashMap<Achievement, AchievementLog>());
|
||||||
|
|
||||||
//Record that achievement has leveled up
|
//Record that achievement has leveled up
|
||||||
if (type.getLevelData(event.getValueAfter()).getLevel() > type.getLevelData(event.getValueBefore()).getLevel())
|
if (type.getLevelData(event.getValueAfter()).getLevel() > type.getLevelData(event.getValueBefore()).getLevel())
|
||||||
{
|
{
|
||||||
@ -71,7 +88,7 @@ public class AchievementManager extends MiniPlugin
|
|||||||
log.Amount += event.getValueAfter() - event.getValueBefore();
|
log.Amount += event.getValueAfter() - event.getValueBefore();
|
||||||
log.LevelUp = true;
|
log.LevelUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Record that there has been changes in this Achievement
|
//Record that there has been changes in this Achievement
|
||||||
else if (!_log.get(player.getName()).containsKey(type))
|
else if (!_log.get(player.getName()).containsKey(type))
|
||||||
@ -92,20 +109,71 @@ public class AchievementManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void AddCommands()
|
||||||
|
{
|
||||||
|
AddCommand(new StatsCommand(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openShop(Player player)
|
||||||
|
{
|
||||||
|
_shop.attemptShopOpen(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openShop(Player player, Player target)
|
||||||
|
{
|
||||||
|
_shop.attemptShopOpen(player, target);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerQuit(PlayerQuitEvent event)
|
public void playerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
_log.remove(event.getPlayer().getName());
|
_log.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void playerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
if (_giveInterfaceItem)
|
||||||
|
{
|
||||||
|
giveInterfaceItem(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clearLog(Player player)
|
public void clearLog(Player player)
|
||||||
{
|
{
|
||||||
_log.remove(player.getName());
|
_log.remove(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public NautHashMap<Achievement, AchievementLog> getLog(Player player)
|
public NautHashMap<Achievement, AchievementLog> getLog(Player player)
|
||||||
{
|
{
|
||||||
return _log.remove(player.getName());
|
return _log.remove(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGiveInterfaceItem(boolean giveInterfaceItem)
|
||||||
|
{
|
||||||
|
_giveInterfaceItem = giveInterfaceItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveInterfaceItem(Player player)
|
||||||
|
{
|
||||||
|
if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.CHEST))
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(_interfaceSlot, ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte)0, 1, ChatColor.RESET + C.cGreen + "/stats"));
|
||||||
|
|
||||||
|
UtilInv.Update(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void openShop(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.hasItem() && event.getItem().getType() == Material.PAPER)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
openShop(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package mineplex.core.achievement.command;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/22/2014.
|
||||||
|
*/
|
||||||
|
public class StatsCommand extends CommandBase<AchievementManager>
|
||||||
|
{
|
||||||
|
public StatsCommand(AchievementManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ALL, "stats");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args == null || args.length == 0)
|
||||||
|
{
|
||||||
|
Plugin.openShop(caller);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugin.openShop(caller, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package mineplex.core.achievement.ui;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.achievement.ui.page.AchievementMainPage;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.ShopBase;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/21/2014.
|
||||||
|
*/
|
||||||
|
public class AchievementShop extends ShopBase<AchievementManager>
|
||||||
|
{
|
||||||
|
private StatsManager _statsManager;
|
||||||
|
|
||||||
|
public AchievementShop(AchievementManager plugin, StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||||
|
{
|
||||||
|
super(plugin, clientManager, donationManager, name);
|
||||||
|
_statsManager = statsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> BuildPagesFor(Player player)
|
||||||
|
{
|
||||||
|
return BuildPagesFor(player, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> BuildPagesFor(Player player, Player target)
|
||||||
|
{
|
||||||
|
return new AchievementMainPage(Plugin, _statsManager, this, ClientManager, DonationManager, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean attemptShopOpen(Player player, Player target)
|
||||||
|
{
|
||||||
|
if (!OpenedShop.contains(player.getName()))
|
||||||
|
{
|
||||||
|
if (!CanOpenShop(player))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OpenedShop.add(player.getName());
|
||||||
|
|
||||||
|
OpenShopForPlayer(player);
|
||||||
|
if (!PlayerPageMap.containsKey(player.getName()))
|
||||||
|
{
|
||||||
|
PlayerPageMap.put(player.getName(), BuildPagesFor(player, target));
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenPageForPlayer(player, GetOpeningPageForPlayer(player));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package mineplex.core.achievement.ui.button;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.AchievementCategory;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.achievement.ui.AchievementShop;
|
||||||
|
import mineplex.core.achievement.ui.page.AchievementPage;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/22/2014.
|
||||||
|
*/
|
||||||
|
public class CategoryButton extends SingleButton
|
||||||
|
{
|
||||||
|
private AchievementShop _shop;
|
||||||
|
private AchievementCategory _category;
|
||||||
|
private AchievementManager _achievementManager;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
_category = category;
|
||||||
|
_shop = shop;
|
||||||
|
_achievementManager = achievementManager;
|
||||||
|
_statsManager = statsManager;
|
||||||
|
_donationManager = donationManager;
|
||||||
|
_clientManager = clientManager;
|
||||||
|
_target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Clicked(Player player)
|
||||||
|
{
|
||||||
|
_shop.OpenPageForPlayer(player, new AchievementPage(_achievementManager, _statsManager, _category, _shop, _clientManager, _donationManager, player, _target));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package mineplex.core.achievement.ui.page;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.Achievement;
|
||||||
|
import mineplex.core.achievement.AchievementCategory;
|
||||||
|
import mineplex.core.achievement.AchievementData;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.achievement.ui.AchievementShop;
|
||||||
|
import mineplex.core.achievement.ui.button.CategoryButton;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.core.stats.PlayerStats;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/21/2014.
|
||||||
|
*/
|
||||||
|
public class AchievementMainPage extends ShopPageBase<AchievementManager, AchievementShop>
|
||||||
|
{
|
||||||
|
private Player _target;
|
||||||
|
private StatsManager _statsManager;
|
||||||
|
|
||||||
|
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Player target)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, target.getName() + "'s Stats", player);
|
||||||
|
|
||||||
|
_target = target;
|
||||||
|
_statsManager = statsManager;
|
||||||
|
|
||||||
|
BuildPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void BuildPage()
|
||||||
|
{
|
||||||
|
int categoryCount = 0;
|
||||||
|
int slot = 10;
|
||||||
|
for (AchievementCategory category : AchievementCategory.values())
|
||||||
|
{
|
||||||
|
CategoryButton button = new CategoryButton(Shop, Plugin, _statsManager, category, DonationManager, ClientManager, _target);
|
||||||
|
|
||||||
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
lore.add(" ");
|
||||||
|
addStats(category, lore, 2);
|
||||||
|
lore.add(" ");
|
||||||
|
addAchievements(category, lore, 3);
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Click for more details!");
|
||||||
|
|
||||||
|
ShopItem shopItem = new ShopItem(category.getIcon(),ChatColor.RESET + C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false);
|
||||||
|
AddButton(slot, shopItem, button);
|
||||||
|
|
||||||
|
slot += 2;
|
||||||
|
categoryCount++;
|
||||||
|
if (categoryCount % 4 == 0)
|
||||||
|
slot += 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addStats(AchievementCategory category, List<String> lore, int max)
|
||||||
|
{
|
||||||
|
String[] statsToDisplay = category.getStatsToDisplay();
|
||||||
|
PlayerStats stats = _statsManager.Get(_target);
|
||||||
|
for (int i = 0; i < statsToDisplay.length && i < max; i++)
|
||||||
|
{
|
||||||
|
String statName = statsToDisplay[i];
|
||||||
|
int statNumber = stats.getStat(category.getFriendlyName() + "." + statName);
|
||||||
|
lore.add(C.cYellow + _statsManager.parseFriendlyStatName(statName) + ": " + C.cWhite + statNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAchievements(AchievementCategory category, List<String> lore, int max)
|
||||||
|
{
|
||||||
|
int achievementCount = 0;
|
||||||
|
for (int i = 0; i < Achievement.values().length && achievementCount < max; i++)
|
||||||
|
{
|
||||||
|
Achievement achievement = Achievement.values()[i];
|
||||||
|
if (achievement.getCategory() == category)
|
||||||
|
{
|
||||||
|
// Don't display achievements that have multiple levels
|
||||||
|
if (achievement.getMaxLevel() > 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
AchievementData data = Plugin.get(_target, achievement);
|
||||||
|
boolean finished = data.getLevel() >= achievement.getMaxLevel();
|
||||||
|
|
||||||
|
lore.add((finished ? C.cGreen : C.cRed) + achievement.getName());
|
||||||
|
|
||||||
|
achievementCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,164 @@
|
|||||||
|
package mineplex.core.achievement.ui.page;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.Achievement;
|
||||||
|
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.util.C;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.core.stats.PlayerStats;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/22/2014.
|
||||||
|
*/
|
||||||
|
public class AchievementPage extends ShopPageBase<AchievementManager, AchievementShop>
|
||||||
|
{
|
||||||
|
private static int ACHIEVEMENT_MIDDLE_INDEX = 31;
|
||||||
|
|
||||||
|
private AchievementCategory _category;
|
||||||
|
private StatsManager _statsManager;
|
||||||
|
private Player _target;
|
||||||
|
|
||||||
|
public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Player target)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, category.getFriendlyName(), player);
|
||||||
|
|
||||||
|
_statsManager = statsManager;
|
||||||
|
_category = category;
|
||||||
|
_target = target;
|
||||||
|
|
||||||
|
BuildPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void BuildPage()
|
||||||
|
{
|
||||||
|
int currentIndex = ACHIEVEMENT_MIDDLE_INDEX - (getAchievements().size() / 2);
|
||||||
|
PlayerStats stats = _statsManager.Get(_target);
|
||||||
|
boolean hasAllAchievements = true;
|
||||||
|
int achievementCount = 0;
|
||||||
|
|
||||||
|
ArrayList<String> masterAchievementLore = new ArrayList<String>();
|
||||||
|
masterAchievementLore.add(" ");
|
||||||
|
|
||||||
|
List<Achievement> achievements = getAchievements();
|
||||||
|
for (Achievement achievement : achievements)
|
||||||
|
{
|
||||||
|
AchievementData data = Plugin.get(_target, achievement);
|
||||||
|
boolean singleLevel = achievement.isSingleLevel();
|
||||||
|
boolean hasUnlocked = data.getLevel() >= achievement.getMaxLevel();
|
||||||
|
|
||||||
|
if (!hasUnlocked)
|
||||||
|
{
|
||||||
|
hasAllAchievements = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Material material = hasUnlocked ? Material.EMERALD : Material.INK_SACK;
|
||||||
|
String itemName = hasUnlocked ? C.cGreen : C.cRed + achievement.getName();
|
||||||
|
|
||||||
|
if (!singleLevel)
|
||||||
|
itemName += ChatColor.WHITE + " Level " + data.getLevel() + "/" + achievement.getMaxLevel();
|
||||||
|
|
||||||
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
lore.add(" ");
|
||||||
|
for (String descLine : achievement.getDesc())
|
||||||
|
{
|
||||||
|
lore.add(ChatColor.RESET + descLine);
|
||||||
|
}
|
||||||
|
lore.add(" ");
|
||||||
|
|
||||||
|
if (!hasUnlocked && achievement.isOngoing())
|
||||||
|
lore.add(C.cYellow + (singleLevel ? "Next Level: " : "To Unlock: ") + C.cWhite + data.getExpRemainder() + "/" + data.getExpNextLevel());
|
||||||
|
|
||||||
|
AddItem(currentIndex, new ShopItem(material, (byte) (hasUnlocked ? 0 : 8), itemName, lore.toArray(new String[0]), 1, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
masterAchievementLore.add((hasUnlocked ? C.cGreen : C.cRed) + achievement.getName());
|
||||||
|
|
||||||
|
currentIndex++;
|
||||||
|
achievementCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Master Achievement
|
||||||
|
if (!_category.getFriendlyName().startsWith("Global") && achievementCount > 0)
|
||||||
|
{
|
||||||
|
String itemName = ChatColor.RESET + _category.getFriendlyName() + " Master Achievement";
|
||||||
|
masterAchievementLore.add(" ");
|
||||||
|
masterAchievementLore.add(ChatColor.RESET + "Reward coming soon!");
|
||||||
|
|
||||||
|
AddItem(40, new ShopItem(Material.WOOL, (byte) (hasAllAchievements ? 5 : 14), itemName, masterAchievementLore.toArray(new String[0]), 1, false, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
addBackButton();
|
||||||
|
addStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addBackButton()
|
||||||
|
{
|
||||||
|
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void Clicked(Player player)
|
||||||
|
{
|
||||||
|
Shop.OpenPageForPlayer(Player, new AchievementMainPage(Plugin, _statsManager, Shop, ClientManager, DonationManager, player, _target));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addStats()
|
||||||
|
{
|
||||||
|
// Don't show if this category has no stats to display
|
||||||
|
if (_category.getStatsToDisplay().length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Material material = Material.BOOK;
|
||||||
|
String itemName = C.Bold + _category.getFriendlyName() + " Stats";
|
||||||
|
List<String> lore = new ArrayList<String>();
|
||||||
|
lore.add("");
|
||||||
|
|
||||||
|
PlayerStats stats = _statsManager.Get(_target);
|
||||||
|
for (String statName : _category.getStatsToDisplay())
|
||||||
|
{
|
||||||
|
int statNumber = stats.getStat(_category.getFriendlyName() + "." + statName);
|
||||||
|
String name = statName.substring(statName.lastIndexOf('.') + 1);
|
||||||
|
lore.add(C.cYellow + _statsManager.parseFriendlyStatName(name) + ": " + C.cWhite + statNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(material);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RESET + itemName);
|
||||||
|
meta.setLore(lore);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
setItem(22, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Achievement> getAchievements()
|
||||||
|
{
|
||||||
|
List<Achievement> achievements = new ArrayList<Achievement>();
|
||||||
|
|
||||||
|
for (Achievement achievement : Achievement.values())
|
||||||
|
{
|
||||||
|
if (achievement.getCategory() == _category)
|
||||||
|
achievements.add(achievement);
|
||||||
|
}
|
||||||
|
|
||||||
|
return achievements;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package mineplex.core.cosmetic.ui;
|
package mineplex.core.cosmetic.ui;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
@ -8,10 +9,13 @@ import mineplex.core.common.CurrencyType;
|
|||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
||||||
|
import mineplex.core.cosmetic.ui.page.TreasurePage;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.shop.ShopBase;
|
import mineplex.core.shop.ShopBase;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
||||||
{
|
{
|
||||||
@ -44,4 +48,17 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void updateTreasure(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (ShopPageBase<CosmeticManager, ? extends ShopBase<CosmeticManager>> shop : PlayerPageMap.values())
|
||||||
|
{
|
||||||
|
if (shop instanceof TreasurePage)
|
||||||
|
((TreasurePage) shop).update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
|
import mineplex.core.shop.item.IButton;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
|
public class TreasureButton extends SingleButton
|
||||||
|
{
|
||||||
|
|
||||||
|
private Menu _menu;
|
||||||
|
|
||||||
|
public TreasureButton(Menu menu)
|
||||||
|
{
|
||||||
|
_menu = menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Clicked(Player player)
|
||||||
|
{
|
||||||
|
// _menu.openTreasure(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.core.cosmetic.ui.page;
|
package mineplex.core.cosmetic.ui.page;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ import mineplex.core.cosmetic.ui.button.OpenMorphs;
|
|||||||
import mineplex.core.cosmetic.ui.button.OpenMounts;
|
import mineplex.core.cosmetic.ui.button.OpenMounts;
|
||||||
import mineplex.core.cosmetic.ui.button.OpenParticles;
|
import mineplex.core.cosmetic.ui.button.OpenParticles;
|
||||||
import mineplex.core.cosmetic.ui.button.OpenPets;
|
import mineplex.core.cosmetic.ui.button.OpenPets;
|
||||||
|
import mineplex.core.cosmetic.ui.button.TreasureButton;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
@ -40,18 +42,28 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
protected void BuildPage()
|
protected void BuildPage()
|
||||||
{
|
{
|
||||||
AddItem(11, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
|
AddItem(11, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
|
||||||
AddItem(13, new ShopItem(Material.CHEST, C.cGold + Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest") + " Treasure Chests", 1, false));
|
|
||||||
|
int treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
|
||||||
|
|
||||||
|
// if (treasureChestCount > 0)
|
||||||
|
// {
|
||||||
|
// AddButton(13, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests", new String[] { ChatColor.RESET + "Click to Open Treasure Chest" }, 1, false), new TreasureButton(this));
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
AddItem(13, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests", 1, false));
|
||||||
|
// }
|
||||||
|
|
||||||
final GemBooster gemBoosterItem = new GemBooster(Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
|
final GemBooster gemBoosterItem = new GemBooster(Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
|
||||||
|
|
||||||
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gemBoosterItem.GetCost(CurrencyType.Coins))
|
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gemBoosterItem.GetCost(CurrencyType.Coins))
|
||||||
{
|
{
|
||||||
AddButton(15, new ShopItem(
|
AddButton(15, new ShopItem(
|
||||||
gemBoosterItem.GetDisplayMaterial(),
|
gemBoosterItem.GetDisplayMaterial(),
|
||||||
gemBoosterItem.GetDisplayName(),
|
gemBoosterItem.GetDisplayName(),
|
||||||
gemBoosterItem.GetDescription(),
|
gemBoosterItem.GetDescription(),
|
||||||
1,
|
1,
|
||||||
false),
|
false),
|
||||||
new SingleButton()
|
new SingleButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -72,24 +84,24 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddItem(15, new ShopItem(
|
AddItem(15, new ShopItem(
|
||||||
gemBoosterItem.GetDisplayMaterial(),
|
gemBoosterItem.GetDisplayMaterial(),
|
||||||
gemBoosterItem.GetDisplayName(),
|
gemBoosterItem.GetDisplayName(),
|
||||||
gemBoosterItem.GetDescription(),
|
gemBoosterItem.GetDescription(),
|
||||||
1,
|
1,
|
||||||
false));
|
false));
|
||||||
}
|
}
|
||||||
|
|
||||||
AddButton(27, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
AddButton(27, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
||||||
AddButton(29, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
AddButton(29, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
||||||
AddButton(31, new ShopItem(Material.LEASH, "Pets", 1, false), new OpenPets(this));
|
AddButton(31, new ShopItem(Material.LEASH, "Pets", 1, false), new OpenPets(this));
|
||||||
AddButton(33, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this));
|
AddButton(33, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this));
|
||||||
AddButton(35, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
AddButton(35, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
||||||
|
|
||||||
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Particle) != null)
|
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Particle) != null)
|
||||||
{
|
{
|
||||||
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle);
|
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle);
|
||||||
|
|
||||||
AddButton(36,
|
AddButton(36,
|
||||||
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
||||||
new SingleButton()
|
new SingleButton()
|
||||||
{
|
{
|
||||||
@ -102,12 +114,12 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Item) != null)
|
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Item) != null)
|
||||||
{
|
{
|
||||||
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item);
|
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item);
|
||||||
|
|
||||||
AddButton(38,
|
AddButton(38,
|
||||||
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
||||||
new SingleButton()
|
new SingleButton()
|
||||||
{
|
{
|
||||||
@ -120,7 +132,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Plugin.getPetManager().hasActivePet(Player.getName()))
|
if (Plugin.getPetManager().hasActivePet(Player.getName()))
|
||||||
{
|
{
|
||||||
AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false),
|
AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false),
|
||||||
@ -135,12 +147,12 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Plugin.getMountManager().getActive(Player) != null)
|
if (Plugin.getMountManager().getActive(Player) != null)
|
||||||
{
|
{
|
||||||
final Mount<?> mount = Plugin.getMountManager().getActive(Player);
|
final Mount<?> mount = Plugin.getMountManager().getActive(Player);
|
||||||
|
|
||||||
AddButton(42,
|
AddButton(42,
|
||||||
new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), C.mItem + mount.GetName(), new String[] {}, 1, false, false),
|
new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), C.mItem + mount.GetName(), new String[] {}, 1, false, false),
|
||||||
new SingleButton()
|
new SingleButton()
|
||||||
{
|
{
|
||||||
@ -153,12 +165,12 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Morph) != null)
|
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Morph) != null)
|
||||||
{
|
{
|
||||||
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph);
|
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph);
|
||||||
|
|
||||||
AddButton(44,
|
AddButton(44,
|
||||||
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
||||||
new SingleButton()
|
new SingleButton()
|
||||||
{
|
{
|
||||||
@ -178,6 +190,11 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
Shop.OpenPageForPlayer(player, new ParticlePage(Plugin, Shop, ClientManager, DonationManager, "Particles", player));
|
Shop.OpenPageForPlayer(player, new ParticlePage(Plugin, Shop, ClientManager, DonationManager, "Particles", player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openTreasure(Player player)
|
||||||
|
{
|
||||||
|
Shop.OpenPageForPlayer(player, new TreasurePage(Plugin, Shop, ClientManager, DonationManager, "Open Treasure Chest", player));
|
||||||
|
}
|
||||||
|
|
||||||
public void openGadgets(Player player)
|
public void openGadgets(Player player)
|
||||||
{
|
{
|
||||||
Shop.OpenPageForPlayer(player, new GadgetPage(Plugin, Shop, ClientManager, DonationManager, "Gadgets", player));
|
Shop.OpenPageForPlayer(player, new GadgetPage(Plugin, Shop, ClientManager, DonationManager, "Gadgets", player));
|
||||||
|
@ -0,0 +1,178 @@
|
|||||||
|
package mineplex.core.cosmetic.ui.page;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
|
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Shaun on 8/22/2014.
|
||||||
|
*/
|
||||||
|
public class TreasurePage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This is unfinished
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final int[] ROTATION_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 17, 26, 35, 34, 33, 32, 31, 30, 29, 28, 27, 18, 9 };
|
||||||
|
private static final List<Integer> CHEST_SLOTS = Arrays.asList(new Integer[] {3 + 9 + 9, 6 + 9 + 9, 2 + 9 + 9, 4 + 9 + 9, 5 + 9 + 9});
|
||||||
|
private static final List<ChatColor> CHEST_COLORS = Arrays.asList(new ChatColor[] {ChatColor.RED, ChatColor.GREEN, ChatColor.YELLOW, ChatColor.BLUE, ChatColor.AQUA, ChatColor.GOLD});
|
||||||
|
|
||||||
|
// Used to animate the gui
|
||||||
|
private int _ticks;
|
||||||
|
private Random _random;
|
||||||
|
|
||||||
|
// Used for blocks that rotate around the gui
|
||||||
|
private short _rotationColorOne = 0;
|
||||||
|
private short _rotationColorTwo = 0;
|
||||||
|
private boolean _rotationForwardOne = true;
|
||||||
|
private boolean _rotationForwardTwo = false;
|
||||||
|
private int _currentIndexOne = 4;
|
||||||
|
private int _currentIndexTwo = 4;
|
||||||
|
|
||||||
|
// Is the animation done, can the player select a chest?
|
||||||
|
public boolean _canSelectChest = false;
|
||||||
|
|
||||||
|
// Queues for Chest Colors and Slots
|
||||||
|
private LinkedList<ChatColor> _colors;
|
||||||
|
private LinkedList<Integer> _chestSlots;
|
||||||
|
|
||||||
|
public TreasurePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager, String name, Player player)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, name, player, 9 * 4);
|
||||||
|
_random = new Random();
|
||||||
|
|
||||||
|
// Shuffle random _colors and chest positions
|
||||||
|
_colors = new LinkedList<ChatColor>(CHEST_COLORS);
|
||||||
|
_chestSlots = new LinkedList<Integer>(CHEST_SLOTS);
|
||||||
|
Collections.shuffle(_colors, _random);
|
||||||
|
Collections.shuffle(_chestSlots, _random);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void BuildPage()
|
||||||
|
{
|
||||||
|
int treasureCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
|
||||||
|
|
||||||
|
_rotationColorOne = _ticks % 2 == 0 ? ((short) _random.nextInt(15)) : _rotationColorOne;
|
||||||
|
_rotationColorTwo = _ticks % 20 == 0 ? ((short) _random.nextInt(15)) : _rotationColorTwo;
|
||||||
|
ItemStack borderPane = new ItemStack(Material.STAINED_GLASS_PANE, 1, _canSelectChest ? (short) 7 : (short) 15);
|
||||||
|
|
||||||
|
// Set all the border panes
|
||||||
|
for (int row = 0; row < 4; row++)
|
||||||
|
{
|
||||||
|
if (row == 0 || row == 3)
|
||||||
|
{
|
||||||
|
for (int column = 0; column < 9; column++)
|
||||||
|
{
|
||||||
|
setItem(column, row, borderPane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setItem(0, row, borderPane);
|
||||||
|
setItem(8, row, borderPane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_ticks <= 21)
|
||||||
|
{
|
||||||
|
rotateBorderPanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_ticks == 0)
|
||||||
|
{
|
||||||
|
Player.playSound(Player.getEyeLocation(), Sound.ANVIL_USE, 4, 1);
|
||||||
|
}
|
||||||
|
else if (_ticks == 20)
|
||||||
|
{
|
||||||
|
Player.playSound(Player.getEyeLocation(), Sound.CHEST_OPEN, 4, 1);
|
||||||
|
}
|
||||||
|
else if (_ticks >= 30 && _ticks <= 120 && _ticks % 20 == 0)
|
||||||
|
{
|
||||||
|
ChatColor color = _colors.poll();
|
||||||
|
String colorName = color.name().toLowerCase();
|
||||||
|
colorName = colorName.substring(0, 1).toUpperCase() + colorName.substring(1);
|
||||||
|
String chestName = color + colorName + " Chest";
|
||||||
|
String[] lore = new String[] { ChatColor.RESET.toString() + ChatColor.WHITE + "Click to Open" };
|
||||||
|
|
||||||
|
|
||||||
|
Player.playSound(Player.getEyeLocation(), Sound.NOTE_PLING, 4, 1);
|
||||||
|
final int slot = _chestSlots.poll();
|
||||||
|
AddButton(slot, new ShopItem(Material.CHEST, chestName, lore, 1, false), new SingleButton()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void Clicked(Player player)
|
||||||
|
{
|
||||||
|
if (_canSelectChest)
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.CHEST_OPEN, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (_ticks == 140)
|
||||||
|
{
|
||||||
|
Player.playSound(Player.getEyeLocation(), Sound.LEVEL_UP, 4, 1F);
|
||||||
|
ItemStack is = new ItemStack(Material.BOOK);
|
||||||
|
ItemMeta meta = is.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RESET.toString() + "Select a Chest");
|
||||||
|
is.setItemMeta(meta);
|
||||||
|
|
||||||
|
setItem(9 + 4, is);
|
||||||
|
addGlow(9 + 4);
|
||||||
|
|
||||||
|
_canSelectChest = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ticks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotateBorderPanes()
|
||||||
|
{
|
||||||
|
ItemStack whitePane = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0);
|
||||||
|
ItemStack paneOne = new ItemStack(Material.STAINED_GLASS_PANE, 1, _rotationColorOne);
|
||||||
|
ItemStack paneTwo = new ItemStack(Material.STAINED_GLASS_PANE, 1, _rotationColorTwo);
|
||||||
|
|
||||||
|
_currentIndexOne = (_currentIndexOne + (_rotationForwardOne ? 1 : -1)) % ROTATION_SLOTS.length;
|
||||||
|
if (_currentIndexOne < 0)
|
||||||
|
_currentIndexOne = _currentIndexOne + ROTATION_SLOTS.length;
|
||||||
|
|
||||||
|
_currentIndexTwo = (_currentIndexTwo + (_rotationForwardTwo ? 1 : -1)) % ROTATION_SLOTS.length;
|
||||||
|
if (_currentIndexTwo < 0)
|
||||||
|
_currentIndexTwo = _currentIndexTwo + ROTATION_SLOTS.length;
|
||||||
|
|
||||||
|
if (_currentIndexOne == _currentIndexTwo)
|
||||||
|
{
|
||||||
|
setItem(ROTATION_SLOTS[_currentIndexOne], whitePane);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setItem(ROTATION_SLOTS[_currentIndexOne], paneOne);
|
||||||
|
setItem(ROTATION_SLOTS[_currentIndexTwo], paneTwo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
BuildPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,6 +6,7 @@ import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventoryCustom;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
@ -73,7 +74,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void BuildPage();
|
protected abstract void BuildPage();
|
||||||
|
|
||||||
protected void AddItem(int slot, ShopItem item)
|
protected void AddItem(int slot, ShopItem item)
|
||||||
{
|
{
|
||||||
if (slot > inventory.getSize() - 1)
|
if (slot > inventory.getSize() - 1)
|
||||||
@ -169,4 +170,9 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
|||||||
clear();
|
clear();
|
||||||
BuildPage();
|
BuildPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItem(int column, int row, ItemStack itemStack)
|
||||||
|
{
|
||||||
|
setItem(column + (row * 9), itemStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,4 +163,29 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String parseFriendlyStatName(String statName)
|
||||||
|
{
|
||||||
|
statName = statName.substring(statName.lastIndexOf(".") + 1);
|
||||||
|
|
||||||
|
int lastBreak = 0;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < statName.length(); i++)
|
||||||
|
{
|
||||||
|
char c = statName.charAt(i);
|
||||||
|
if (Character.isUpperCase(c))
|
||||||
|
{
|
||||||
|
sb.append(statName.substring(lastBreak, i) + " ");
|
||||||
|
lastBreak = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == statName.length() - 1)
|
||||||
|
{
|
||||||
|
sb.append(statName.substring(lastBreak));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString().trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import mineplex.core.MiniClientPlugin;
|
|||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -111,6 +112,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
private PreferencesManager _preferences;
|
private PreferencesManager _preferences;
|
||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
private NewsManager _news;
|
private NewsManager _news;
|
||||||
|
private AchievementManager _achievementManager;
|
||||||
private PollManager _pollManager;
|
private PollManager _pollManager;
|
||||||
|
|
||||||
private Location _spawn;
|
private Location _spawn;
|
||||||
@ -167,6 +169,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
AddCommand(new ForcefieldRadius(_forcefieldManager));
|
AddCommand(new ForcefieldRadius(_forcefieldManager));
|
||||||
|
|
||||||
_statsManager = new StatsManager(plugin);
|
_statsManager = new StatsManager(plugin);
|
||||||
|
_achievementManager = new AchievementManager(_statsManager, _clientManager, _donationManager);
|
||||||
|
_achievementManager.setGiveInterfaceItem(true);
|
||||||
|
|
||||||
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
||||||
|
|
||||||
|
@ -210,8 +210,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
}
|
}
|
||||||
|
|
||||||
_statsManager = new StatsManager(plugin);
|
_statsManager = new StatsManager(plugin);
|
||||||
_taskManager = new TaskManager(plugin, webAddress);
|
_taskManager = new TaskManager(plugin, webAddress);
|
||||||
_achievementManager = new AchievementManager(_statsManager);
|
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
_cosmeticManager = cosmeticManager;
|
_cosmeticManager = cosmeticManager;
|
||||||
_portal = portal;
|
_portal = portal;
|
||||||
|
@ -3,8 +3,8 @@ package nautilus.game.arcade.managers;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import mineplex.core.achievement.Achievement;
|
import mineplex.core.achievement.Achievement;
|
||||||
|
import mineplex.core.achievement.AchievementData;
|
||||||
import mineplex.core.achievement.AchievementLog;
|
import mineplex.core.achievement.AchievementLog;
|
||||||
import mineplex.core.achievement.AchivementData;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -84,7 +84,7 @@ public class GameAchievementManager implements Listener
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(player, "");
|
UtilPlayer.message(player, "");
|
||||||
|
|
||||||
AchivementData data = Manager.GetAchievement().get(player, type);
|
AchievementData data = Manager.GetAchievement().get(player, type);
|
||||||
|
|
||||||
String nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel());
|
String nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel());
|
||||||
String progress = F.elem(C.cGreen + "+" + log.get(type).Amount);
|
String progress = F.elem(C.cGreen + "+" + log.get(type).Amount);
|
||||||
|
Loading…
Reference in New Issue
Block a user