diff --git a/Plugins/Libraries/craftbukkit.jar b/Plugins/Libraries/craftbukkit.jar index f5492b351..9eee19943 100644 Binary files a/Plugins/Libraries/craftbukkit.jar and b/Plugins/Libraries/craftbukkit.jar differ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/RankBenefitsGiver9000.java b/Plugins/Mineplex.Core/src/mineplex/core/RankBenefitsGiver9000.java new file mode 100644 index 000000000..e8d8e7615 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/RankBenefitsGiver9000.java @@ -0,0 +1,82 @@ +package mineplex.core; + +import java.util.HashSet; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.RetrieveClientInformationEvent; +import mineplex.core.common.Rank; +import mineplex.core.inventory.InventoryManager; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class RankBenefitsGiver9000 extends MiniPlugin +{ + private CoreClientManager _clientManager; + private InventoryManager _inventoryManager; + private RankBenefitsGiver9000Repository _repository; + + private HashSet _playersNeedingBenefit = new HashSet(); + + public RankBenefitsGiver9000(JavaPlugin plugin, CoreClientManager clientManager, InventoryManager inventoryManager) + { + super("RankBenefitsGiver9000", plugin); + + _clientManager = clientManager; + _inventoryManager = inventoryManager; + _repository = new RankBenefitsGiver9000Repository(plugin); + } + + @EventHandler + public void loadPlayer(RetrieveClientInformationEvent event) + { + boolean treasureUpdate = false; + + for (String benefit : _repository.retrievePlayerBenefits(event.getUniqueId().toString())) + { + if (benefit.equalsIgnoreCase("TreasureUpdate")) + treasureUpdate = true; + } + + if (!treasureUpdate) + { + _playersNeedingBenefit.add(event.getPlayerName()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void giveBenefit(final PlayerJoinEvent event) + { + if (!_playersNeedingBenefit.contains(event.getPlayer().getName())) + return; + + if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL) + { + _inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 1); + _inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 1); + } + else if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ULTRA) + { + _inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 20); + _inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 5); + } + else + { + _inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 40); + _inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 10); + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + _repository.addBenefit(event.getPlayer().getUniqueId().toString(), "TreasureUpdate"); + } + }); + + _playersNeedingBenefit.remove(event.getPlayer().getName()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/RankBenefitsGiver9000Repository.java b/Plugins/Mineplex.Core/src/mineplex/core/RankBenefitsGiver9000Repository.java new file mode 100644 index 000000000..a7abdbb4b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/RankBenefitsGiver9000Repository.java @@ -0,0 +1,59 @@ +package mineplex.core; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnVarChar; + +import org.bukkit.plugin.java.JavaPlugin; + +public class RankBenefitsGiver9000Repository extends RepositoryBase +{ + private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));"; + + private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);"; + private static String RETRIEVE_BENEFITS = "SELECT benefit FROM rankBenefits WHERE uuid = ?;"; + + public RankBenefitsGiver9000Repository(JavaPlugin plugin) + { + super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE_BENEFIT_TABLE); + } + + @Override + protected void update() + { + } + + public List retrievePlayerBenefits(String uuid) + { + final List benefits = new ArrayList(); + + executeQuery(RETRIEVE_BENEFITS, new ResultSetCallable() + { + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + benefits.add(resultSet.getString(1)); + } + } + }, new ColumnVarChar("uuid", 100, uuid)); + + return benefits; + } + + public void addBenefit(String uuid, String benefit) + { + executeUpdate(INSERT_BENEFIT, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("benefit", 100, benefit)); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 264d08406..788dd6d93 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -38,6 +38,7 @@ import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; import mineplex.core.MiniClientPlugin; +import mineplex.core.RankBenefitsGiver9000; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.RetrieveClientInformationEvent; @@ -159,6 +160,7 @@ public class HubManager extends MiniClientPlugin _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = new InventoryManager(plugin); + new RankBenefitsGiver9000(plugin, clientManager, _inventoryManager); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin)); _treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false, _treasureManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index 50f34ac1e..09df7f5b2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -185,7 +185,7 @@ public class ServerNpcPage extends ShopPageBase im int greenStartSlot = 18 + ((9 - serversToShow) / 2); boolean showGreen = true; - boolean beta = serverList.size() > 0 && serverList.get(0).Name.contains("BETA"); + boolean beta = serverList.size() > 0 && (serverList.get(0).Name.contains("BETA") || serverList.get(0).Name.contains("MS-")); boolean tournament = serverList.size() > 0 && serverList.get(0).Name.contains("T_"); boolean ownsUltraPackage = DonationManager.Get(Player.getName()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA") || Client.GetRank().Has(Rank.ULTRA); diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 6a1f5de2e..18194052c 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ