Structure for Mail system, not finished yet.

This commit is contained in:
Shaun Bennett 2014-11-20 14:41:25 -06:00
parent 4961b55986
commit a73ee4e306
13 changed files with 435 additions and 3 deletions

View File

@ -11,7 +11,7 @@ package mineplex.database;
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Account extends org.jooq.impl.SchemaImpl implements java.io.Serializable, java.lang.Cloneable {
private static final long serialVersionUID = 1357303848;
private static final long serialVersionUID = 477510632;
/**
* The singleton instance of <code>Account</code>
@ -46,11 +46,13 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali
mineplex.database.tables.Games.games,
mineplex.database.tables.ItemCategories.itemCategories,
mineplex.database.tables.Items.items,
mineplex.database.tables.Mail.mail,
mineplex.database.tables.Npcs.npcs,
mineplex.database.tables.PlayerMap.playerMap,
mineplex.database.tables.Polls.polls,
mineplex.database.tables.RankBenefits.rankBenefits,
mineplex.database.tables.RewardLog.rewardLog,
mineplex.database.tables.ServerPassword.serverPassword,
mineplex.database.tables.Stats.stats,
mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard);
}

View File

@ -30,11 +30,13 @@ public class Keys {
public static final org.jooq.Identity<mineplex.database.tables.records.GamesRecord, java.lang.Integer> IDENTITY_games = Identities0.IDENTITY_games;
public static final org.jooq.Identity<mineplex.database.tables.records.ItemCategoriesRecord, java.lang.Integer> IDENTITY_itemCategories = Identities0.IDENTITY_itemCategories;
public static final org.jooq.Identity<mineplex.database.tables.records.ItemsRecord, java.lang.Integer> IDENTITY_items = Identities0.IDENTITY_items;
public static final org.jooq.Identity<mineplex.database.tables.records.MailRecord, java.lang.Integer> IDENTITY_mail = Identities0.IDENTITY_mail;
public static final org.jooq.Identity<mineplex.database.tables.records.NpcsRecord, java.lang.Integer> IDENTITY_npcs = Identities0.IDENTITY_npcs;
public static final org.jooq.Identity<mineplex.database.tables.records.PlayerMapRecord, java.lang.Integer> IDENTITY_playerMap = Identities0.IDENTITY_playerMap;
public static final org.jooq.Identity<mineplex.database.tables.records.PollsRecord, java.lang.Integer> IDENTITY_polls = Identities0.IDENTITY_polls;
public static final org.jooq.Identity<mineplex.database.tables.records.RankBenefitsRecord, java.lang.Integer> IDENTITY_rankBenefits = Identities0.IDENTITY_rankBenefits;
public static final org.jooq.Identity<mineplex.database.tables.records.RewardLogRecord, java.lang.Integer> IDENTITY_rewardLog = Identities0.IDENTITY_rewardLog;
public static final org.jooq.Identity<mineplex.database.tables.records.ServerPasswordRecord, java.lang.Integer> IDENTITY_serverPassword = Identities0.IDENTITY_serverPassword;
public static final org.jooq.Identity<mineplex.database.tables.records.StatsRecord, java.lang.Integer> IDENTITY_stats = Identities0.IDENTITY_stats;
public static final org.jooq.Identity<mineplex.database.tables.records.TournamentLeaderboardRecord, java.lang.Integer> IDENTITY_tournamentLeaderboard = Identities0.IDENTITY_tournamentLeaderboard;
@ -62,12 +64,14 @@ public class Keys {
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ItemCategoriesRecord> KEY_itemCategories_nameIndex = UniqueKeys0.KEY_itemCategories_nameIndex;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ItemsRecord> KEY_items_PRIMARY = UniqueKeys0.KEY_items_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ItemsRecord> KEY_items_uniqueNameCategoryIndex = UniqueKeys0.KEY_items_uniqueNameCategoryIndex;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.MailRecord> KEY_mail_PRIMARY = UniqueKeys0.KEY_mail_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.NpcsRecord> KEY_npcs_PRIMARY = UniqueKeys0.KEY_npcs_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_PRIMARY = UniqueKeys0.KEY_playerMap_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_playerIndex = UniqueKeys0.KEY_playerMap_playerIndex;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PollsRecord> KEY_polls_PRIMARY = UniqueKeys0.KEY_polls_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.RankBenefitsRecord> KEY_rankBenefits_PRIMARY = UniqueKeys0.KEY_rankBenefits_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord> KEY_rewardLog_PRIMARY = UniqueKeys0.KEY_rewardLog_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ServerPasswordRecord> KEY_serverPassword_PRIMARY = UniqueKeys0.KEY_serverPassword_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_PRIMARY = UniqueKeys0.KEY_stats_PRIMARY;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_nameIndex = UniqueKeys0.KEY_stats_nameIndex;
public static final org.jooq.UniqueKey<mineplex.database.tables.records.TournamentLeaderboardRecord> KEY_tournamentLeaderboard_PRIMARY = UniqueKeys0.KEY_tournamentLeaderboard_PRIMARY;
@ -88,6 +92,7 @@ public class Keys {
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.GamesRecord> FK_gamePlayers_games = ForeignKeys0.FK_gamePlayers_games;
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.AccountsRecord> FK_gamePlayers_accounts = ForeignKeys0.FK_gamePlayers_accounts;
public static final org.jooq.ForeignKey<mineplex.database.tables.records.ItemsRecord, mineplex.database.tables.records.ItemCategoriesRecord> items_ibfk_1 = ForeignKeys0.items_ibfk_1;
public static final org.jooq.ForeignKey<mineplex.database.tables.records.MailRecord, mineplex.database.tables.records.AccountsRecord> mail_ibfk_1 = ForeignKeys0.mail_ibfk_1;
public static final org.jooq.ForeignKey<mineplex.database.tables.records.RewardLogRecord, mineplex.database.tables.records.AccountsRecord> rewardLog_ibfk_1 = ForeignKeys0.rewardLog_ibfk_1;
public static final org.jooq.ForeignKey<mineplex.database.tables.records.TournamentLeaderboardRecord, mineplex.database.tables.records.AccountsRecord> FK_tournamentLeaderboard_accounts = ForeignKeys0.FK_tournamentLeaderboard_accounts;
@ -108,11 +113,13 @@ public class Keys {
public static org.jooq.Identity<mineplex.database.tables.records.GamesRecord, java.lang.Integer> IDENTITY_games = createIdentity(mineplex.database.tables.Games.games, mineplex.database.tables.Games.games.id);
public static org.jooq.Identity<mineplex.database.tables.records.ItemCategoriesRecord, java.lang.Integer> IDENTITY_itemCategories = createIdentity(mineplex.database.tables.ItemCategories.itemCategories, mineplex.database.tables.ItemCategories.itemCategories.id);
public static org.jooq.Identity<mineplex.database.tables.records.ItemsRecord, java.lang.Integer> IDENTITY_items = createIdentity(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.id);
public static org.jooq.Identity<mineplex.database.tables.records.MailRecord, java.lang.Integer> IDENTITY_mail = createIdentity(mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.id);
public static org.jooq.Identity<mineplex.database.tables.records.NpcsRecord, java.lang.Integer> IDENTITY_npcs = createIdentity(mineplex.database.tables.Npcs.npcs, mineplex.database.tables.Npcs.npcs.id);
public static org.jooq.Identity<mineplex.database.tables.records.PlayerMapRecord, java.lang.Integer> IDENTITY_playerMap = createIdentity(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.id);
public static org.jooq.Identity<mineplex.database.tables.records.PollsRecord, java.lang.Integer> IDENTITY_polls = createIdentity(mineplex.database.tables.Polls.polls, mineplex.database.tables.Polls.polls.id);
public static org.jooq.Identity<mineplex.database.tables.records.RankBenefitsRecord, java.lang.Integer> IDENTITY_rankBenefits = createIdentity(mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankBenefits.rankBenefits.id);
public static org.jooq.Identity<mineplex.database.tables.records.RewardLogRecord, java.lang.Integer> IDENTITY_rewardLog = createIdentity(mineplex.database.tables.RewardLog.rewardLog, mineplex.database.tables.RewardLog.rewardLog.id);
public static org.jooq.Identity<mineplex.database.tables.records.ServerPasswordRecord, java.lang.Integer> IDENTITY_serverPassword = createIdentity(mineplex.database.tables.ServerPassword.serverPassword, mineplex.database.tables.ServerPassword.serverPassword.id);
public static org.jooq.Identity<mineplex.database.tables.records.StatsRecord, java.lang.Integer> IDENTITY_stats = createIdentity(mineplex.database.tables.Stats.stats, mineplex.database.tables.Stats.stats.id);
public static org.jooq.Identity<mineplex.database.tables.records.TournamentLeaderboardRecord, java.lang.Integer> IDENTITY_tournamentLeaderboard = createIdentity(mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.id);
}
@ -138,12 +145,14 @@ public class Keys {
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ItemCategoriesRecord> KEY_itemCategories_nameIndex = createUniqueKey(mineplex.database.tables.ItemCategories.itemCategories, mineplex.database.tables.ItemCategories.itemCategories.name);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ItemsRecord> KEY_items_PRIMARY = createUniqueKey(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ItemsRecord> KEY_items_uniqueNameCategoryIndex = createUniqueKey(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.name, mineplex.database.tables.Items.items.categoryId);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.MailRecord> KEY_mail_PRIMARY = createUniqueKey(mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.NpcsRecord> KEY_npcs_PRIMARY = createUniqueKey(mineplex.database.tables.Npcs.npcs, mineplex.database.tables.Npcs.npcs.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_PRIMARY = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_playerIndex = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.playerName);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PollsRecord> KEY_polls_PRIMARY = createUniqueKey(mineplex.database.tables.Polls.polls, mineplex.database.tables.Polls.polls.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.RankBenefitsRecord> KEY_rankBenefits_PRIMARY = createUniqueKey(mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankBenefits.rankBenefits.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord> KEY_rewardLog_PRIMARY = createUniqueKey(mineplex.database.tables.RewardLog.rewardLog, mineplex.database.tables.RewardLog.rewardLog.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.ServerPasswordRecord> KEY_serverPassword_PRIMARY = createUniqueKey(mineplex.database.tables.ServerPassword.serverPassword, mineplex.database.tables.ServerPassword.serverPassword.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_PRIMARY = createUniqueKey(mineplex.database.tables.Stats.stats, mineplex.database.tables.Stats.stats.id);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_nameIndex = createUniqueKey(mineplex.database.tables.Stats.stats, mineplex.database.tables.Stats.stats.name);
public static final org.jooq.UniqueKey<mineplex.database.tables.records.TournamentLeaderboardRecord> KEY_tournamentLeaderboard_PRIMARY = createUniqueKey(mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.id);
@ -162,6 +171,7 @@ public class Keys {
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.GamesRecord> FK_gamePlayers_games = createForeignKey(mineplex.database.Keys.KEY_games_PRIMARY, mineplex.database.tables.GamePlayers.gamePlayers, mineplex.database.tables.GamePlayers.gamePlayers.gameId);
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.AccountsRecord> FK_gamePlayers_accounts = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.GamePlayers.gamePlayers, mineplex.database.tables.GamePlayers.gamePlayers.accountId);
public static final org.jooq.ForeignKey<mineplex.database.tables.records.ItemsRecord, mineplex.database.tables.records.ItemCategoriesRecord> items_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_itemCategories_PRIMARY, mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.categoryId);
public static final org.jooq.ForeignKey<mineplex.database.tables.records.MailRecord, mineplex.database.tables.records.AccountsRecord> mail_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.accountId);
public static final org.jooq.ForeignKey<mineplex.database.tables.records.RewardLogRecord, mineplex.database.tables.records.AccountsRecord> rewardLog_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.RewardLog.rewardLog, mineplex.database.tables.RewardLog.rewardLog.accountId);
public static final org.jooq.ForeignKey<mineplex.database.tables.records.TournamentLeaderboardRecord, mineplex.database.tables.records.AccountsRecord> FK_tournamentLeaderboard_accounts = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.accountId);
}

View File

@ -73,6 +73,11 @@ public class Tables {
*/
public static final mineplex.database.tables.Items items = mineplex.database.tables.Items.items;
/**
* The table Account.mail
*/
public static final mineplex.database.tables.Mail mail = mineplex.database.tables.Mail.mail;
/**
* The table Account.npcs
*/
@ -98,6 +103,11 @@ public class Tables {
*/
public static final mineplex.database.tables.RewardLog rewardLog = mineplex.database.tables.RewardLog.rewardLog;
/**
* The table Account.serverPassword
*/
public static final mineplex.database.tables.ServerPassword serverPassword = mineplex.database.tables.ServerPassword.serverPassword;
/**
* The table Account.stats
*/

View File

@ -17,6 +17,7 @@
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="commons-dbcp2" level="project" />
<orderEntry type="library" name="commons-pool2" level="project" />
<orderEntry type="module" module-name="Mineplex.Database" />
<orderEntry type="library" name="jooq" level="project" />
</component>
</module>
</module>

View File

@ -83,6 +83,7 @@ import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.mail.MailManager;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.MapManager;
@ -190,6 +191,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
_achievementManager.setGiveInterfaceItem(true);
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
// new MailManager(_plugin, _clientManager, _donationManager);
_ruleBook = ItemStackFactory.Instance.CreateStack(Material.WRITTEN_BOOK, (byte)0, 1, ChatColor.GREEN + "Rule Book", new String[] { });
BookMeta meta = (BookMeta)_ruleBook.getItemMeta();

View File

@ -0,0 +1,63 @@
package mineplex.hub.mail;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.donation.DonationManager;
import mineplex.hub.mail.command.MailCommand;
import mineplex.hub.mail.gui.MailShop;
/**
* Created by shaun on 14-11-20.
*/
public class MailManager extends MiniClientPlugin<PlayerMailData>
{
private MailRepository _repository;
private MailShop _shop;
public MailManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Mail", plugin);
_repository = new MailRepository(plugin);
_shop = new MailShop(this, clientManager, donationManager);
}
@Override
protected PlayerMailData AddPlayer(String player)
{
return new PlayerMailData();
}
@Override
protected void loadClientInformation(final RetrieveClientInformationEvent event)
{
event.incrementProcessingCount();
runAsync(new Runnable()
{
@Override
public void run()
{
Set(event.getPlayerName(), _repository.loadMailData(event.getUniqueId()));
event.decreaseProcessingCount();
}
});
}
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
}
@Override
public void AddCommands()
{
addCommand(new MailCommand(this));
}
}

View File

@ -0,0 +1,86 @@
package mineplex.hub.mail;
import java.sql.Timestamp;
/**
* Created by shaun on 14-11-20.
*/
public class MailMessage
{
private int _messageId;
private String _sender;
private String _message;
private boolean _archived;
private boolean _deleted;
private Timestamp _timeSent;
public MailMessage(int messageId, String sender, String message, boolean archived, boolean deleted, Timestamp timeSent)
{
_messageId = messageId;
_sender = sender;
_message = message;
_archived = archived;
_deleted = deleted;
_timeSent = timeSent;
}
public int getMessageId()
{
return _messageId;
}
public void setMessageId(int messageId)
{
_messageId = messageId;
}
public String getSender()
{
return _sender;
}
public void setSender(String sender)
{
_sender = sender;
}
public String getMessage()
{
return _message;
}
public void setMessage(String message)
{
_message = message;
}
public boolean isArchived()
{
return _archived;
}
public void setArchived(boolean archived)
{
_archived = archived;
}
public boolean isDeleted()
{
return _deleted;
}
public void setDeleted(boolean deleted)
{
_deleted = deleted;
}
public Timestamp getTimeSent()
{
return _timeSent;
}
public void setTimeSent(Timestamp timeSent)
{
_timeSent = timeSent;
}
}

View File

@ -0,0 +1,60 @@
package mineplex.hub.mail;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.RepositoryBase;
import mineplex.database.Tables;
import mineplex.database.tables.records.MailRecord;
import org.jooq.DSLContext;
import org.jooq.Result;
import org.jooq.impl.DSL;
/**
* Created by shaun on 14-11-20.
*/
public class MailRepository extends RepositoryBase
{
public MailRepository(JavaPlugin plugin)
{
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
public PlayerMailData loadMailData(UUID uuid)
{
PlayerMailData data = new PlayerMailData();
DSLContext context = DSL.using(getConnection());
Result<MailRecord> resultSet = context.selectFrom(Tables.mail).where(Tables.mail.accountId.eq(DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(uuid.toString())))
).fetch();
for (MailRecord record : resultSet)
{
data.getMessages().add(createMessage(record));
}
return data;
}
private MailMessage createMessage(MailRecord record)
{
return new MailMessage(record.getId(), record.getSender(), record.getMessage(), (record.getArchived() & 0x01) != 0, (record.getDeleted() & 0x01) != 0, record.getTimeSent());
}
}

View File

@ -0,0 +1,37 @@
package mineplex.hub.mail;
import java.util.ArrayList;
import java.util.List;
import mineplex.database.tables.records.MailRecord;
/**
* Created by shaun on 14-11-20.
*/
public class PlayerMailData
{
private List<MailMessage> _messages;
public PlayerMailData()
{
_messages = new ArrayList<MailMessage>();
}
public List<MailMessage> getMessages()
{
return _messages;
}
public List<MailMessage> getUnreadMessages()
{
ArrayList<MailMessage> unreadMessages = new ArrayList<MailMessage>();
for (MailMessage message : _messages)
{
if (!(message.isArchived() || message.isDeleted()))
unreadMessages.add(message);
}
return unreadMessages;
}
}

View File

@ -0,0 +1,34 @@
package mineplex.hub.mail.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.hub.mail.MailManager;
import mineplex.hub.mail.MailMessage;
import mineplex.hub.mail.PlayerMailData;
/**
* Created by shaun on 14-11-20.
*/
public class MailCommand extends CommandBase<MailManager>
{
public MailCommand(MailManager plugin)
{
super(plugin, Rank.ALL, "mail");
}
@Override
public void Execute(Player caller, String[] args)
{
PlayerMailData mailData = Plugin.Get(caller);
for (MailMessage message : mailData.getMessages())
{
caller.sendMessage(message.getMessage());
}
Plugin.openShop(caller);
}
}

View File

@ -0,0 +1,28 @@
package mineplex.hub.mail.gui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.mail.MailManager;
import mineplex.hub.mail.gui.page.MailPage;
/**
* Created by shaun on 14-11-20.
*/
public class MailShop extends ShopBase<MailManager>
{
public MailShop(MailManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Mail Shop");
}
@Override
protected ShopPageBase<MailManager, ? extends ShopBase<MailManager>> BuildPagesFor(Player player)
{
return new MailPage(Plugin, this, ClientManager, DonationManager, player);
}
}

View File

@ -0,0 +1,35 @@
package mineplex.hub.mail.gui.button;
import org.bukkit.entity.Player;
import mineplex.core.shop.item.IButton;
import mineplex.hub.mail.MailMessage;
import mineplex.hub.mail.gui.page.MailPage;
/**
* Created by shaun on 14-11-20.
*/
public class MailButton implements IButton
{
private MailPage _page;
private MailMessage _message;
public MailButton(MailPage page, MailMessage message)
{
_page = page;
_message = message;
}
@Override
public void ClickedLeft(Player player)
{
_page.Refresh();
}
@Override
public void ClickedRight(Player player)
{
_page.Refresh();
}
}

View File

@ -0,0 +1,63 @@
package mineplex.hub.mail.gui.page;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.mail.MailManager;
import mineplex.hub.mail.MailMessage;
import mineplex.hub.mail.gui.MailShop;
import mineplex.hub.mail.gui.button.MailButton;
/**
* Created by shaun on 14-11-20.
*/
public class MailPage extends ShopPageBase<MailManager, MailShop>
{
public MailPage(MailManager plugin, MailShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Mail", player);
Refresh();
}
@Override
protected void BuildPage()
{
List<MailMessage> messages = Plugin.Get(Player.getName()).getMessages();
for (int i = 0; i < messages.size(); i++)
{
MailMessage message = messages.get(i);
ShopItem item = getItem(message);
System.out.println(message.getMessage());
AddButton(i, item, new MailButton(this, message));
}
}
private ShopItem getItem(MailMessage message)
{
ShopItem shopItem = new ShopItem(Material.PAPER, "Mail Message", parseMessage(message), 1, false);
return shopItem;
}
private String[] parseMessage(MailMessage message)
{
String[] lines = new String[5];
lines[0] = "From: " + message.getSender();
lines[1] = "Message: " + message.getMessage();
lines[2] = "Deleted: " + message.isDeleted();
lines[3] = "Archived: " + message.isArchived();
return lines;
}
}