changing Hub items and adding Profile GUI.

This commit is contained in:
Sarah 2015-08-09 18:33:44 +02:00
parent 941e746ca9
commit 8c66ef7f15
12 changed files with 301 additions and 61 deletions

View File

@ -137,15 +137,6 @@ public class AchievementManager extends MiniPlugin
_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());
@ -161,22 +152,7 @@ public class AchievementManager extends MiniPlugin
_giveInterfaceItem = giveInterfaceItem; _giveInterfaceItem = giveInterfaceItem;
} }
public void giveInterfaceItem(Player player) /*@EventHandler
{
if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.SKULL_ITEM))
{
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats");
SkullMeta meta = ((SkullMeta) item.getItemMeta());
meta.setOwner(player.getName());
item.setItemMeta(meta);
player.getInventory().setItem(_interfaceSlot, item);
UtilInv.Update(player);
}
}
@EventHandler
public void openShop(PlayerInteractEvent event) public void openShop(PlayerInteractEvent event)
{ {
if (!_shopEnabled) if (!_shopEnabled)
@ -188,7 +164,7 @@ public class AchievementManager extends MiniPlugin
openShop(event.getPlayer()); openShop(event.getPlayer());
} }
} }*/
public boolean hasCategory(Player player, Achievement[] required) public boolean hasCategory(Player player, Achievement[] required)
{ {

View File

@ -10,7 +10,7 @@ public class HostServerCommand extends CommandBase<PersonalServerManager>
{ {
public HostServerCommand(PersonalServerManager plugin) public HostServerCommand(PersonalServerManager plugin)
{ {
super(plugin, Rank.LEGEND, "hostserver"); super(plugin, Rank.LEGEND, "hostserver", "mps");
} }
@Override @Override

View File

@ -59,7 +59,6 @@ public class PersonalServerManager extends MiniPlugin
{ {
if (_giveInterfaceItem) if (_giveInterfaceItem)
{ {
event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem);
} }
} }

View File

@ -4,6 +4,19 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,18 +24,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences> public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
private PreferencesRepository _repository; private PreferencesRepository _repository;
@ -53,6 +58,27 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller)); _saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
} }
@EventHandler
public void givePlayerItem(PlayerJoinEvent event)
{
if (!GiveItem)
return;
Player player = event.getPlayer();
if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM))
{
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "My Profile");
SkullMeta meta = ((SkullMeta) item.getItemMeta());
meta.setOwner(player.getName());
item.setItemMeta(meta);
player.getInventory().setItem(8, item);
UtilInv.Update(player);
}
}
@EventHandler @EventHandler
public void storeBuffer(UpdateEvent event) public void storeBuffer(UpdateEvent event)
{ {
@ -77,15 +103,6 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
}); });
} }
@EventHandler
public void givePlayerItem(PlayerJoinEvent event)
{
if (!GiveItem)
return;
event.getPlayer().getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs"));
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void playerInteract(PlayerInteractEvent event) public void playerInteract(PlayerInteractEvent event)
{ {

View File

@ -122,7 +122,9 @@ public class Hub extends JavaPlugin implements IRelation
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager); PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager);
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
@ -141,7 +143,7 @@ public class Hub extends JavaPlugin implements IRelation
} }
}); });
//new Replay(this, packetHandler); //new Replay(this, packetHandler);
new PersonalServerManager(this, clientManager);
AprilFoolsManager.Initialize(this, clientManager, disguiseManager); AprilFoolsManager.Initialize(this, clientManager, disguiseManager);

View File

@ -25,6 +25,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -74,6 +75,7 @@ import mineplex.core.notifier.NotificationManager;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
import mineplex.core.party.Party; import mineplex.core.party.Party;
import mineplex.core.party.PartyManager; import mineplex.core.party.PartyManager;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.pet.PetManager; import mineplex.core.pet.PetManager;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
@ -97,6 +99,7 @@ import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.TextManager; import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.WorldManager; import mineplex.hub.modules.WorldManager;
import mineplex.hub.poll.PollManager; import mineplex.hub.poll.PollManager;
import mineplex.hub.profile.gui.GUIProfile;
import mineplex.hub.tutorial.TutorialManager; import mineplex.hub.tutorial.TutorialManager;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
@ -130,6 +133,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private AchievementManager _achievementManager; private AchievementManager _achievementManager;
private TreasureManager _treasureManager; private TreasureManager _treasureManager;
private PetManager _petManager; private PetManager _petManager;
private PersonalServerManager _personalServerManager;
private Location _spawn; private Location _spawn;
private int _scoreboardTick = 0; private int _scoreboardTick = 0;
@ -150,7 +154,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Admin //Admin
private boolean _gadgetsEnabled = true; private boolean _gadgetsEnabled = true;
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager) public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager)
{ {
super("Hub Manager", plugin); super("Hub Manager", plugin);
@ -160,6 +164,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_donationManager = donationManager; _donationManager = donationManager;
_disguiseManager = disguiseManager; _disguiseManager = disguiseManager;
_pollManager = pollManager; _pollManager = pollManager;
_personalServerManager = personalServerManager;
_portal = portal; _portal = portal;
@ -1094,4 +1099,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false)));
} }
} }
@EventHandler
public void openProfile(PlayerInteractEvent event)
{
if(event.getItem().getType() != Material.SKULL_ITEM)
return;
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();;
}
} }

View File

@ -56,14 +56,14 @@ public class PollButton extends SimpleGui implements GuiItem {
if (_poll != null) if (_poll != null)
{ {
setItem(4, getQuestionItem(_poll.getQuestion())); setItem(13, getQuestionItem(_poll.getQuestion()));
int[] slots = even(9, _poll.getAnswers().length); int[] slots = even(9, _poll.getAnswers().length);
for (int i = 0; i < slots.length; i++) for (int i = 0; i < slots.length; i++)
{ {
AnswerItem item = new AnswerItem(_poll, i); AnswerItem item = new AnswerItem(_poll, i);
setItem(9 * 2 + slots[i], item); setItem(9 * 3 + slots[i], item);
} }
} }
} }
@ -80,16 +80,17 @@ public class PollButton extends SimpleGui implements GuiItem {
} }
else else
{ {
lore.add("");
lore.add(C.cWhite + _poll.getQuestion()); lore.add(C.cWhite + _poll.getQuestion());
lore.add(""); lore.add("");
int i = 1; int i = 1;
for(String str : _poll.getAnswers()) for(String str : _poll.getAnswers())
{ {
lore.add(C.cAqua + "" + i + ".) " + str); lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
i++; i++;
} }
lore.add(""); lore.add("");
lore.add(C.cYellow + C.Bold + "Reward: 500 Gems"); lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
lore.add(""); lore.add("");
lore.add(C.cGreen + "Click to go to the vote page!"); lore.add(C.cGreen + "Click to go to the vote page!");
return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore); return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore);
@ -112,8 +113,24 @@ public class PollButton extends SimpleGui implements GuiItem {
public GuiItem getQuestionItem(String question) public GuiItem getQuestionItem(String question)
{ {
return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + "Question:",
wrap(question))); ArrayList<String> lore = new ArrayList<>();
lore.add("");
lore.add(C.cWhite + wrap(question));
lore.add("");
int i = 1;
for(String str : _poll.getAnswers())
{
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
i++;
}
lore.add("");
lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
lore.add("");
lore.add(C.cGreen + "Click to go to the vote page!");
return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + C.cGreen + C.Bold + "Vote on Poll",
lore));
} }
public static String[] wrap(String text) public static String[] wrap(String text)
@ -158,8 +175,10 @@ public class PollButton extends SimpleGui implements GuiItem {
@Override @Override
public ItemStack getObject() public ItemStack getObject()
{ {
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "" + (num + 1) + ":", wrap(getPoll() ArrayList<String> lore = new ArrayList<>();
.getAnswers()[num])); lore.add("");
lore.add(getPoll().getAnswers()[num]);
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore);
} }
@Override @Override

View File

@ -149,9 +149,9 @@ public class RankBonusButton implements GuiItem, Listener {
lore.add(" "); lore.add(" ");
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!"); lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
lore.add(ChatColor.WHITE + ""); lore.add(ChatColor.WHITE + "");
lore.add(ChatColor.AQUA + "Ultra: 7500 Coins"); lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
lore.add(ChatColor.LIGHT_PURPLE + "Hero: 15000 Coins"); lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
lore.add(ChatColor.GREEN + "Legend: 30000 Coins"); lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
lore.add(ChatColor.WHITE + ""); lore.add(ChatColor.WHITE + "");
lore.add(ChatColor.WHITE + "Purchase a Rank at;"); lore.add(ChatColor.WHITE + "Purchase a Rank at;");
lore.add(ChatColor.WHITE + "www.mineplex.com/shop"); lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
@ -197,7 +197,15 @@ public class RankBonusButton implements GuiItem, Listener {
public boolean isAvailable() public boolean isAvailable()
{ {
if (!hasRank) if (!hasRank)
{
UtilPlayer.message(getPlayer(), "----------------------------------------");
UtilPlayer.message(getPlayer(), "");
UtilPlayer.message(getPlayer(), "Purchase a Rank at the Mineplex Shop:");
UtilPlayer.message(getPlayer(), C.cGreen + "www.mineplex.com/shop");
UtilPlayer.message(getPlayer(), "");
UtilPlayer.message(getPlayer(), "----------------------------------------");
return false; return false;
}
return (timeLeft() <= 0); return (timeLeft() <= 0);
} }

View File

@ -0,0 +1,51 @@
package mineplex.hub.profile.buttons;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.hub.profile.gui.GUIProfile;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public class ButtonMPS implements GuiItem
{
private GUIProfile _profile;
private Player _player;
public ButtonMPS(GUIProfile profile, Player player)
{
_profile = profile;
_player = player;
}
@Override
public void click(ClickType clickType)
{
_profile.getPersonalManager().showHostMessage(_player);
}
@Override
public ItemStack getObject()
{
return ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + "/hostserver");
}
@Override
public void setup()
{
}
@Override
public void close()
{
}
}

View File

@ -0,0 +1,51 @@
package mineplex.hub.profile.buttons;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.hub.profile.gui.GUIProfile;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public class ButtonPrefs implements GuiItem
{
private GUIProfile _profile;
private Player _player;
public ButtonPrefs(GUIProfile profile, Player player)
{
_profile = profile;
_player = player;
}
@Override
public void click(ClickType clickType)
{
_profile.getPrefManager().openShop(_player);
}
@Override
public ItemStack getObject()
{
return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs");
}
@Override
public void setup()
{
}
@Override
public void close()
{
}
}

View File

@ -0,0 +1,55 @@
package mineplex.hub.profile.buttons;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.hub.profile.gui.GUIProfile;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public class ButtonStats implements GuiItem
{
private GUIProfile _profile;
private Player _player;
public ButtonStats(GUIProfile profile, Player player)
{
_profile = profile;
_player = player;
}
@Override
public void click(ClickType clickType)
{
_profile.getAchievementManager().openShop(_player);
}
@Override
public ItemStack getObject()
{
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats");
SkullMeta meta = ((SkullMeta) item.getItemMeta());
meta.setOwner(_player.getName());
item.setItemMeta(meta);
return item;
}
@Override
public void setup()
{
}
@Override
public void close()
{
}
}

View File

@ -0,0 +1,48 @@
package mineplex.hub.profile.gui;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.gui.SimpleGui;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.hub.profile.buttons.ButtonMPS;
import mineplex.hub.profile.buttons.ButtonPrefs;
import mineplex.hub.profile.buttons.ButtonStats;
public class GUIProfile extends SimpleGui
{
private PreferencesManager _preferencesManager;
private AchievementManager _achievementManager;
private PersonalServerManager _personalServerManager;
public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager, PersonalServerManager personalServerManager)
{
super(plugin, player, "My Profile", 9*3);
_preferencesManager = preferencesManager;
_achievementManager = achievementManager;
_personalServerManager = personalServerManager;
setItem(11, new ButtonStats(this, player));
setItem(13, new ButtonMPS(this, player));
setItem(15, new ButtonPrefs(this, player));
}
public PreferencesManager getPrefManager()
{
return _preferencesManager;
}
public AchievementManager getAchievementManager()
{
return _achievementManager;
}
public PersonalServerManager getPersonalManager()
{
return _personalServerManager;
}
}