diff --git a/Art/Carl.png b/Art/Carl.png
new file mode 100644
index 000000000..5d4fe6d36
Binary files /dev/null and b/Art/Carl.png differ
diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml
index d164c4c6a..0527ee7d4 100644
--- a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml
+++ b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml
@@ -1,5 +1,5 @@
-
+
$PROJECT_DIR$/../Testing/Hub/plugins
diff --git a/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml
new file mode 100644
index 000000000..372114469
--- /dev/null
+++ b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml
@@ -0,0 +1,24 @@
+
+
+ $PROJECT_DIR$/out/artifacts/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plugins/.idea/libraries/bukkit.xml b/Plugins/.idea/libraries/bukkit.xml
deleted file mode 100644
index 8053b86f3..000000000
--- a/Plugins/.idea/libraries/bukkit.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Plugins/.idea/modules.xml b/Plugins/.idea/modules.xml
index bf0ac4bae..bcc0470f4 100644
--- a/Plugins/.idea/modules.xml
+++ b/Plugins/.idea/modules.xml
@@ -17,6 +17,7 @@
+
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java
index c3513308c..72ce23304 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java
@@ -85,5 +85,11 @@ public class UtilMath
return Math.random() * d;
}
+
+ public static T randomElement(T[] array) {
+ if (array.length == 0)
+ return null;
+ return array[random.nextInt(array.length)];
+ }
}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
index 322a55134..321f16789 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
@@ -6,20 +6,23 @@ import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
+import net.minecraft.server.v1_7_R4.EntityPlayer;
+import net.minecraft.server.v1_7_R4.Packet;
+import net.minecraft.server.v1_7_R4.PlayerConnection;
+
import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryView;
import org.bukkit.util.Vector;
-import net.minecraft.server.v1_7_R4.Packet;
-import net.minecraft.server.v1_7_R4.PlayerConnection;
-
public class UtilPlayer
{
private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max)
@@ -608,7 +611,19 @@ public class UtilPlayer
return ((CraftPlayer) player).getHandle().spectating;
return false;
}
-
+
+ public static InventoryView swapToInventory(Player player, Inventory inv) {
+
+ EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
+ if (nmsPlayer.activeContainer != nmsPlayer.defaultContainer)
+ {
+ // Do this so that other inventories know their time is over.
+ CraftEventFactory.handleInventoryCloseEvent(nmsPlayer);
+ nmsPlayer.m();
+ }
+ return player.openInventory(inv);
+ }
+
/*
public void setListName(Player player, CoreClient client)
{
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java
index 4ae8f94dc..4372b6fba 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java
@@ -2,6 +2,8 @@ package mineplex.core.common.util;
import java.util.Collection;
+import org.apache.commons.lang.WordUtils;
+
public class UtilText {
public static String listToString(Collection inputList, boolean comma) {
String out = "";
@@ -84,4 +86,13 @@ public class UtilText {
return false;
}
+
+ public static String[] wrap(String text, int lineLength)
+ {
+ return wrap(text, lineLength, true);
+ }
+
+ public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) {
+ return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0");
+ }
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java
index f2b2a0016..481bda4dd 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java
@@ -2,6 +2,7 @@ package mineplex.core.account;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
@@ -50,6 +51,7 @@ public class CoreClientManager extends MiniPlugin
private RedisDataRepository _accountCacheRepository;
private NautHashMap _loginProcessors = new NautHashMap();
+ private LinkedList _querylessLoginProcessors = new LinkedList();
private Object _clientLock = new Object();
@@ -110,7 +112,7 @@ public class CoreClientManager extends MiniPlugin
{
_clientList.remove(name);
}
-
+
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name));
}
@@ -138,6 +140,16 @@ public class CoreClientManager extends MiniPlugin
return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get());
}
+ /**
+ * Get the databse account id for a player. Requires the player is online
+ * @param player
+ * @return
+ */
+ public int getAccountId(Player player)
+ {
+ return Get(player).getAccountId();
+ }
+
@EventHandler(priority = EventPriority.LOWEST)
public void AsyncLogin(AsyncPlayerPreLoginEvent event)
{
@@ -224,7 +236,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank));
- client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
+ client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@@ -264,7 +276,7 @@ public class CoreClientManager extends MiniPlugin
{
public void run()
{
- client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
+ client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
_clientLoginLock.remove(client.GetPlayerName());
}
});
@@ -454,7 +466,7 @@ public class CoreClientManager extends MiniPlugin
callback.run(matchedName);
return;
}
-
+
callback.run(matchedName);
}
}, caller, playerName, true);
@@ -485,7 +497,9 @@ public class CoreClientManager extends MiniPlugin
clientIterator.remove();
if (clientPlayer != null)
+ {
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName()));
+ }
}
}
}
@@ -507,6 +521,11 @@ public class CoreClientManager extends MiniPlugin
{
_loginProcessors.put(processor.getName(), processor);
}
+
+ public void addStoredProcedureLoginProcessor(IQuerylessLoginProcessor processor)
+ {
+ _querylessLoginProcessors.add(processor);
+ }
public boolean hasRank(Player player, Rank rank)
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java
new file mode 100644
index 000000000..7c69bb1c1
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java
@@ -0,0 +1,6 @@
+package mineplex.core.account;
+
+public interface IQuerylessLoginProcessor
+{
+ public void processLogin(String playerName, int accountId);
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java
index 60f756748..c8dccb23e 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java
@@ -6,6 +6,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
@@ -14,6 +15,7 @@ import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.ILoginProcessor;
+import mineplex.core.account.IQuerylessLoginProcessor;
import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank;
@@ -55,7 +57,7 @@ public class AccountRepository extends RepositoryBase
//executeUpdate(CREATE_ACCOUNT_TABLE);
}
- public int login(NautHashMap loginProcessors, String uuid, String name)
+ public int login(NautHashMap loginProcessors, LinkedList querylessLoginProcessors, String uuid, String name)
{
int accountId = -1;
try (
@@ -145,6 +147,11 @@ public class AccountRepository extends RepositoryBase
loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet());
statement.getMoreResults();
}
+
+ for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors)
+ {
+ loginProcessor.processLogin(name, accountId);
+ }
}
catch (Exception exception)
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java
index 485f5a124..76e58b6fb 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java
@@ -137,15 +137,6 @@ public class AchievementManager extends MiniPlugin
_log.remove(event.getPlayer().getName());
}
- @EventHandler
- public void playerJoin(PlayerJoinEvent event)
- {
- if (_giveInterfaceItem)
- {
- giveInterfaceItem(event.getPlayer());
- }
- }
-
public void clearLog(Player player)
{
_log.remove(player.getName());
@@ -161,22 +152,7 @@ public class AchievementManager extends MiniPlugin
_giveInterfaceItem = giveInterfaceItem;
}
- public void giveInterfaceItem(Player player)
- {
- 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
+ /*@EventHandler
public void openShop(PlayerInteractEvent event)
{
if (!_shopEnabled)
@@ -188,7 +164,7 @@ public class AchievementManager extends MiniPlugin
openShop(event.getPlayer());
}
- }
+ }*/
public boolean hasCategory(Player player, Achievement[] required)
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java
new file mode 100644
index 000000000..d2cfef1f8
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java
@@ -0,0 +1,156 @@
+package mineplex.core.bonuses;
+
+import java.util.List;
+
+import mineplex.core.common.util.C;
+
+public class BonusAmount
+{
+ private int _gems;
+ private int _coins;
+ private int _gold;
+ private int _bonusGems;
+ private int _bonusCoins;
+ private int _bonusGold;
+ private int _experience;
+ private int _bonusExperience;
+ private int _tickets;
+
+ public BonusAmount()
+ {
+
+ }
+
+ public int getGems()
+ {
+ return _gems;
+ }
+
+ public void setGems(int gems)
+ {
+ _gems = gems;
+ }
+
+ public int getCoins()
+ {
+ return _coins;
+ }
+
+ public void setCoins(int coins)
+ {
+ _coins = coins;
+ }
+
+ public int getGold()
+ {
+ return _gold;
+ }
+
+ public void setGold(int gold)
+ {
+ _gold = gold;
+ }
+
+ public int getBonusGems()
+ {
+ return _bonusGems;
+ }
+
+ public void setBonusGems(int bonusGems)
+ {
+ _bonusGems = bonusGems;
+ }
+
+ public int getBonusCoins()
+ {
+ return _bonusCoins;
+ }
+
+ public void setBonusCoins(int bonusCoins)
+ {
+ _bonusCoins = bonusCoins;
+ }
+
+ public int getBonusGold()
+ {
+ return _bonusGold;
+ }
+
+ public void setBonusGold(int bonusGold)
+ {
+ _bonusGold = bonusGold;
+ }
+
+ public int getTotalGems()
+ {
+ return getGems() + getBonusGems();
+ }
+
+ public int getTotalCoins()
+ {
+ return getCoins() + getBonusCoins();
+ }
+
+ public int getTotalGold()
+ {
+ return getGold() + getBonusGold();
+ }
+
+ public int getExperience()
+ {
+ return _experience;
+ }
+
+ public void setExperience(int experience)
+ {
+ _experience = experience;
+ }
+
+ public int getBonusExperience()
+ {
+ return _bonusExperience;
+ }
+
+ public void setBonusExperience(int bonusExperience)
+ {
+ _bonusExperience = bonusExperience;
+ }
+
+ public int getTotalExperience()
+ {
+ return getExperience() + getBonusExperience();
+ }
+
+ public int getTickets()
+ {
+ return _tickets;
+ }
+
+ public void setTickets(int tickets)
+ {
+ _tickets = tickets;
+ }
+
+ public boolean isGreaterThanZero()
+ {
+ return _bonusCoins > 0 || _coins > 0 || _bonusGems > 0 || _gems > 0 || _gold > 0 || _bonusGold > 0;
+ }
+
+ public void addLore(List lore)
+ {
+ addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : ""));
+ addLore(lore, getCoins(), getBonusCoins(), "Coins");
+ addLore(lore, getGems(), getBonusGems(), "Gems");
+ addLore(lore, getGold(), getBonusGold(), "Gold");
+ addLore(lore, getExperience(), getBonusExperience(), "Experience");
+ }
+
+ private void addLore(List lore, int amount, int bonus, String suffix)
+ {
+ if (amount > 0)
+ lore.add(C.cYellow + "Reward: " + C.cWhite + amount + " " + suffix);
+
+// if (bonus > 0)
+// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix);
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java
new file mode 100644
index 000000000..08cccac7f
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java
@@ -0,0 +1,123 @@
+package mineplex.core.bonuses;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+
+import mineplex.core.hologram.Hologram;
+import mineplex.database.tables.records.BonusRecord;
+
+public class BonusClientData
+{
+ private BonusRecord _record;
+ private Hologram _hologram;
+
+ public BonusClientData(BonusRecord record)
+ {
+ _record = record;
+ }
+
+ public BonusRecord getRecord()
+ {
+ return _record;
+ }
+
+ public void setAccountId(Integer value)
+ {
+ _record.setAccountId(value);
+ }
+
+ public Integer getAccountId()
+ {
+ return _record.getAccountId();
+ }
+
+ public void setDailyTime(Timestamp value)
+ {
+ _record.setDailytime(value);
+ }
+
+ public Timestamp getDailyTime()
+ {
+ return _record.getDailytime();
+ }
+
+ public void setRankTime(Date value)
+ {
+ _record.setRanktime(value);
+ }
+
+ public Date getRankTime()
+ {
+ return _record.getRanktime();
+ }
+
+ public void setVoteTime(Date value)
+ {
+ _record.setVotetime(value);
+ }
+
+ public Date getVoteTime()
+ {
+ return _record.getVotetime();
+ }
+
+ public void setDailyStreak(Integer value)
+ {
+ _record.setDailyStreak(value);
+ }
+
+ public Integer getDailyStreak()
+ {
+ return _record.getDailyStreak();
+ }
+
+ public void setMaxDailyStreak(Integer value)
+ {
+ _record.setMaxDailyStreak(value);
+ }
+
+ public Integer getMaxDailyStreak()
+ {
+ return _record.getMaxDailyStreak();
+ }
+
+ public void setVoteStreak(Integer value)
+ {
+ _record.setVoteStreak(value);
+ }
+
+ public Integer getVoteStreak()
+ {
+ return _record.getVoteStreak();
+ }
+
+ public void setMaxVoteStreak(Integer value)
+ {
+ _record.setMaxVoteStreak(value);
+ }
+
+ public Integer getMaxVoteStreak()
+ {
+ return _record.getMaxVoteStreak();
+ }
+
+ public void setTickets(Integer value)
+ {
+ _record.setTickets(value);
+ }
+
+ public Integer getTickets()
+ {
+ return _record.getTickets();
+ }
+
+ public Hologram getHologram()
+ {
+ return _hologram;
+ }
+
+ public void setHologram(Hologram hologram)
+ {
+ _hologram = hologram;
+ }
+}
\ No newline at end of file
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
new file mode 100644
index 000000000..fe37f5a42
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
@@ -0,0 +1,1038 @@
+package mineplex.core.bonuses;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.TimeZone;
+
+import mineplex.core.MiniClientPlugin;
+import mineplex.core.account.CoreClient;
+import mineplex.core.account.CoreClientManager;
+import mineplex.core.account.IQuerylessLoginProcessor;
+import mineplex.core.account.event.ClientUnloadEvent;
+import mineplex.core.common.Rank;
+import mineplex.core.common.util.C;
+import mineplex.core.common.util.Callback;
+import mineplex.core.common.util.F;
+import mineplex.core.common.util.UtilParticle;
+import mineplex.core.common.util.UtilPlayer;
+import mineplex.core.common.util.UtilServer;
+import mineplex.core.common.util.UtilParticle.ParticleType;
+import mineplex.core.common.util.UtilParticle.ViewDist;
+import mineplex.core.database.DBPool;
+import mineplex.core.donation.DonationManager;
+import mineplex.core.hologram.Hologram;
+import mineplex.core.hologram.HologramManager;
+import mineplex.core.inventory.InventoryManager;
+import mineplex.core.npc.Npc;
+import mineplex.core.npc.NpcManager;
+import mineplex.core.pet.PetManager;
+import mineplex.core.recharge.Recharge;
+import mineplex.core.reward.RewardManager;
+import mineplex.core.stats.StatsManager;
+import mineplex.core.updater.UpdateType;
+import mineplex.core.updater.event.UpdateEvent;
+import mineplex.core.votifier.VotifierCommand;
+import mineplex.database.Tables;
+import mineplex.core.bonuses.animations.AnimationCarl;
+import mineplex.core.bonuses.commands.AnimationCommand;
+import mineplex.core.bonuses.commands.GuiCommand;
+import mineplex.core.bonuses.commands.TicketCommand;
+import mineplex.core.bonuses.event.CarlSpinnerEvent;
+import mineplex.core.bonuses.gui.BonusGui;
+import mineplex.database.tables.records.BonusRecord;
+import mineplex.core.bonuses.gui.SpinGui;
+import mineplex.core.poll.PollManager;
+import mineplex.serverdata.commands.ServerCommandManager;
+
+import org.jooq.SQLDialect;
+import org.jooq.impl.DSL;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.block.Dropper;
+import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Item;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.player.PlayerInteractEntityEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import net.minecraft.server.v1_7_R4.DataWatcher;
+import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
+
+public class BonusManager extends MiniClientPlugin implements IQuerylessLoginProcessor
+{
+
+ public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
+
+ private static long timeOffSet = 0;
+
+ private ArrayList