Merge branch 'Bonus'
This commit is contained in:
commit
18843c2cc6
BIN
Art/Carl.png
Normal file
BIN
Art/Carl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 345 KiB |
@ -1,5 +1,5 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact name="Mineplex.Hub:test">
|
||||
<artifact build-on-make="true" name="Mineplex.Hub:test">
|
||||
<output-path>$PROJECT_DIR$/../Testing/Hub/plugins</output-path>
|
||||
<root id="root">
|
||||
<element id="artifact" artifact-name="Mineplex.Hub:jar" />
|
||||
|
24
Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml
Normal file
24
Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" build-on-make="true" name="Mineplex.Votifier:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/</output-path>
|
||||
<root id="archive" name="MineplexVotifier.jar">
|
||||
<element id="module-output" name="Mineplex.Votifier" />
|
||||
<element id="module-output" name="Mineplex.Core" />
|
||||
<element id="module-output" name="Mineplex.Core.Common" />
|
||||
<element id="module-output" name="Mineplex.ServerData" />
|
||||
<element id="module-output" name="Mineplex.ServerMonitor" />
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-io-2.4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-logging-1.1.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-codec-1.6.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpclient-4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpcore-4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.Votifier/plugin.yml" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -1,11 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="bukkit">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/Libraries/bukkit.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/Libraries/bukkit.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -17,6 +17,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" filepath="$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" group="Core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" filepath="$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" />
|
||||
</modules>
|
||||
</component>
|
||||
|
@ -85,5 +85,11 @@ public class UtilMath
|
||||
|
||||
return Math.random() * d;
|
||||
}
|
||||
|
||||
public static <T> T randomElement(T[] array) {
|
||||
if (array.length == 0)
|
||||
return null;
|
||||
return array[random.nextInt(array.length)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
@ -609,6 +612,18 @@ public class UtilPlayer
|
||||
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)
|
||||
{
|
||||
|
@ -2,6 +2,8 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
|
||||
public class UtilText {
|
||||
public static <T> String listToString(Collection<T> 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");
|
||||
}
|
||||
}
|
||||
|
@ -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<AccountCache> _accountCacheRepository;
|
||||
|
||||
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
|
||||
|
||||
private Object _clientLock = new Object();
|
||||
|
||||
@ -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());
|
||||
}
|
||||
});
|
||||
@ -485,7 +497,9 @@ public class CoreClientManager extends MiniPlugin
|
||||
clientIterator.remove();
|
||||
|
||||
if (clientPlayer != null)
|
||||
{
|
||||
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -508,6 +522,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)
|
||||
{
|
||||
CoreClient client = Get(player);
|
||||
|
@ -0,0 +1,6 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
public interface IQuerylessLoginProcessor
|
||||
{
|
||||
public void processLogin(String playerName, int accountId);
|
||||
}
|
@ -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<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
||||
public int login(NautHashMap<String, ILoginProcessor> loginProcessors, LinkedList<IQuerylessLoginProcessor> 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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
156
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java
Normal file
156
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java
Normal file
@ -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<String> 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<String> 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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
1038
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
Normal file
1038
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,386 @@
|
||||
package mineplex.core.bonuses;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import mineplex.core.bonuses.gui.SpinGui;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.BonusRecord;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BonusRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private BonusManager _manager;
|
||||
private DonationManager _donationManager;
|
||||
|
||||
public BonusRepository(JavaPlugin plugin, BonusManager bonusManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
_manager = bonusManager;
|
||||
_donationManager = donationManager;
|
||||
}
|
||||
|
||||
public BonusRecord loadRecord(String playerName, int accountId)
|
||||
{
|
||||
DSLContext create = jooq();
|
||||
|
||||
BonusRecord record = create.selectFrom(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne();
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
// Need to create new record!
|
||||
record = create.newRecord(Tables.bonus);
|
||||
record.setAccountId(accountId);
|
||||
record.setDailyStreak(0);
|
||||
record.setMaxDailyStreak(0);
|
||||
record.setVoteStreak(0);
|
||||
record.setMaxVoteStreak(0);
|
||||
record.setTickets(0);
|
||||
record.store(); // Todo - is this necessary?
|
||||
}
|
||||
System.out.println("Loaded record. Daily time: " + record.getDailytime());
|
||||
return record;
|
||||
}
|
||||
|
||||
public void getDailyStreakRecord(Callback<StreakRecord> callback)
|
||||
{
|
||||
getStreakRecord(Tables.bonus.maxDailyStreak, callback);
|
||||
}
|
||||
|
||||
public void getVoteStreakRecord(Callback<StreakRecord> callback)
|
||||
{
|
||||
getStreakRecord(Tables.bonus.maxVoteStreak, callback);
|
||||
}
|
||||
|
||||
private void getStreakRecord(final TableField<BonusRecord, Integer> field, final Callback<StreakRecord> callback)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Record2<String, Integer> record = jooq().select(Tables.accounts.name, field)
|
||||
.from(Tables.bonus.join(Tables.accounts).on(Tables.bonus.accountId.eq(Tables.accounts.id)))
|
||||
.orderBy(field.desc()).limit(1).fetchOne();
|
||||
|
||||
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (record.value1() != null && record.value2() != null)
|
||||
{
|
||||
callback.run(new StreakRecord(record.value1(), record.value2()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptAddTickets(final int accountId, final BonusClientData client, final int tickets, final Callback<Boolean> callback)
|
||||
{
|
||||
if (client.getTickets() + tickets < 0)
|
||||
callback.run(false);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||
create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)).
|
||||
where(Tables.bonus.accountId.eq(accountId)).execute();
|
||||
final int newTickets = create.select(Tables.bonus.tickets).from(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne().value1();
|
||||
|
||||
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
client.setTickets(newTickets);
|
||||
callback.run(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
callback.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptDailyBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
final int coins = 0;
|
||||
final int gems = 0;
|
||||
/*
|
||||
* if (coins == 0 && gems == 0) { result.accept(false); return; }
|
||||
*/
|
||||
final JavaPlugin plug = _manager.getPlugin();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try (Connection connection = getConnection();
|
||||
CallableStatement callableStatement = connection.prepareCall("{call check_daily(?, ?, ?, ?, ?)}"))
|
||||
{
|
||||
callableStatement.setInt(1, accountId);
|
||||
callableStatement.setInt(2, coins);
|
||||
callableStatement.setInt(3, gems);
|
||||
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(5, java.sql.Types.TIMESTAMP);
|
||||
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
final boolean pass = callableStatement.getBoolean(4);
|
||||
|
||||
final Timestamp timeStamp = callableStatement.getTimestamp(5);
|
||||
|
||||
_manager.Get(player).getRecord().update();
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
if (pass)
|
||||
{
|
||||
_manager.Get(player).setDailyTime(new Timestamp(BonusManager.getSqlTime()));
|
||||
result.run(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false);
|
||||
_manager.Get(player).setDailyTime(timeStamp);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false);
|
||||
e.printStackTrace();
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void giveTickets(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final int newTickets = jooq().update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.sub(-1)).
|
||||
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
|
||||
|
||||
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptRankBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (!Recharge.Instance.usable(player, "AttemptRankBonus")) {
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
final int coins = _manager.getRankBonusAmount(player).getCoins();
|
||||
|
||||
if (coins == 0/* && gems == 0 */) {
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final JavaPlugin plug = _manager.getPlugin();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
try (Connection connection = getConnection();
|
||||
CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) {
|
||||
callableStatement.setInt(1, accountId);
|
||||
callableStatement.setInt(2, coins);
|
||||
callableStatement.setInt(3, 0);
|
||||
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(5, java.sql.Types.DATE);
|
||||
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
final boolean pass = callableStatement.getBoolean(4);
|
||||
|
||||
final Date date = callableStatement.getDate(5);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_manager.Get(player).setRankTime(date);
|
||||
|
||||
if (pass)
|
||||
{
|
||||
result.run(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 10, false, false);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false);
|
||||
e.printStackTrace();
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptVoteBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
final int coins = 0;
|
||||
final int gems = 0;
|
||||
|
||||
final JavaPlugin plug = _manager.getPlugin();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
try (Connection connection = getConnection();
|
||||
CallableStatement callableStatement = connection.prepareCall("{call check_vote(?, ?, ?, ?, ?)}")) {
|
||||
callableStatement.setInt(1, accountId);
|
||||
callableStatement.setInt(2, coins);
|
||||
callableStatement.setInt(3, gems);
|
||||
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
|
||||
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
//final boolean pass = callableStatement.getBoolean(4);
|
||||
|
||||
final Date date = callableStatement.getDate(4);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_manager.Get(player).setVoteTime(date);
|
||||
result.run(true);
|
||||
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTimeOffset(final Callback<Long> callback)
|
||||
{
|
||||
final long startTime = System.currentTimeMillis();
|
||||
final Plugin plugin = _manager.getPlugin();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
executeQuery("SELECT CURRENT_TIMESTAMP", new ResultSetCallable() {
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
resultSet.next();
|
||||
|
||||
long theirTimeUnadjusted = resultSet.getTimestamp(1).getTime();
|
||||
|
||||
long ourCurrentTime = System.currentTimeMillis();
|
||||
|
||||
long latencyOffset = (ourCurrentTime - startTime) / 2;
|
||||
|
||||
long theirTime = theirTimeUnadjusted - latencyOffset;
|
||||
|
||||
final long offSet = theirTime - ourCurrentTime;
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
callback.run(offSet);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
executeUpdate(CREATE_BONUS_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.bonuses;
|
||||
|
||||
public class StreakRecord
|
||||
{
|
||||
private String _playerName;
|
||||
private int _streak;
|
||||
|
||||
public StreakRecord(String playerName, int streak)
|
||||
{
|
||||
_playerName = playerName;
|
||||
_streak = streak;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public int getStreak()
|
||||
{
|
||||
return _streak;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.core.bonuses;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.votifier.VotifierCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class VoteHandler implements CommandCallback
|
||||
{
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public VoteHandler(BonusManager bonusManager)
|
||||
{
|
||||
_bonusManager = bonusManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
VotifierCommand v = ((VotifierCommand) command);
|
||||
|
||||
Player player = UtilPlayer.searchExact(v.getPlayerName());
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
_bonusManager.handleVote(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,268 @@
|
||||
package mineplex.core.bonuses.animations;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AnimationCarl extends Animation
|
||||
{
|
||||
|
||||
private boolean _isDone;
|
||||
private Block _creeper;
|
||||
private long _startTime;
|
||||
private Object _type;
|
||||
private Player _player;
|
||||
private Random _random = new Random();
|
||||
|
||||
public AnimationCarl(Entity creeper)
|
||||
{
|
||||
_creeper = creeper.getLocation().getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if(_type instanceof String)
|
||||
{
|
||||
if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL"))
|
||||
{
|
||||
for (int i = 50; i < 60; i++)
|
||||
{
|
||||
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i));
|
||||
Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d));
|
||||
UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false);
|
||||
UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false);
|
||||
coin.setTicksLived(1160);
|
||||
gem.setTicksLived(1160);
|
||||
}
|
||||
}
|
||||
if(((String) _type).contentEquals("RANK"))
|
||||
{
|
||||
for (int i = 50; i < 60; i++)
|
||||
{
|
||||
Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i));
|
||||
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
coin.setTicksLived(1160);
|
||||
}
|
||||
}
|
||||
if(!((String) _type).contentEquals("DAILY")&& !((String) _type).contentEquals("RANK")&& !((String) _type).contentEquals("POLL"))
|
||||
{
|
||||
|
||||
Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
|
||||
Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d));
|
||||
UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false);
|
||||
paper.setTicksLived(1160);
|
||||
for (int i = 50; i < 60; i++)
|
||||
{
|
||||
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d));
|
||||
UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false);
|
||||
gem.setTicksLived(1160);
|
||||
}
|
||||
}
|
||||
finish();
|
||||
}
|
||||
if(_type instanceof Reward)
|
||||
{
|
||||
if(getTicks() == 0)
|
||||
{
|
||||
RewardData rewardData = ((Reward)_type).getFakeRewardData(_player);
|
||||
ItemStack itemStack = rewardData.getDisplayItem();
|
||||
Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack);
|
||||
|
||||
Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
|
||||
|
||||
UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
|
||||
|
||||
item.setTicksLived(1160);
|
||||
}
|
||||
|
||||
if(((Reward)_type).getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
RareAnimation();
|
||||
}
|
||||
else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY)
|
||||
{
|
||||
LegendAnimation();
|
||||
}
|
||||
else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL)
|
||||
{
|
||||
MythicalAnimation();
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinish() {
|
||||
_isDone = true;
|
||||
setTicks(0);
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return _isDone;
|
||||
}
|
||||
|
||||
public void setDone(boolean b)
|
||||
{
|
||||
_isDone = b;
|
||||
}
|
||||
|
||||
public void setTime(long time)
|
||||
{
|
||||
_startTime = time;
|
||||
}
|
||||
|
||||
public void setType(Object type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public void LegendAnimation()
|
||||
{
|
||||
if (getTicks() < 1)
|
||||
{
|
||||
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
|
||||
}
|
||||
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
|
||||
}
|
||||
else if (getTicks() < 35)
|
||||
{
|
||||
double radius = 2 - (getTicks() / 10D * 2);
|
||||
int particleAmount = 20 - (getTicks() * 2);
|
||||
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||
{
|
||||
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void MythicalAnimation()
|
||||
{
|
||||
if (getTicks() < 30)
|
||||
{
|
||||
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
|
||||
}
|
||||
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
|
||||
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
|
||||
}
|
||||
else if (getTicks() < 40)
|
||||
{
|
||||
UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
|
||||
new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
|
||||
|
||||
//Particle Spiral Up
|
||||
double radius = getTicks() / 20D;
|
||||
int particleAmount = getTicks() / 2;
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
|
||||
Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
|
||||
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
for(double e = 0.1 ; e < 3 ; e += 0.5)
|
||||
{
|
||||
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void RareAnimation()
|
||||
{
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false);
|
||||
}
|
||||
_creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F);
|
||||
}
|
||||
else if (getTicks() >= 60)
|
||||
{
|
||||
finish();
|
||||
}
|
||||
|
||||
else if (getTicks() < 35)
|
||||
{
|
||||
double radius = 2 - (getTicks() / 10D * 2);
|
||||
int particleAmount = 20 - (getTicks() * 2);
|
||||
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||
{
|
||||
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
|
||||
public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
|
||||
private BonusManager _plugin;
|
||||
|
||||
public AnimationCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "animation");
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
|
||||
if(args != null)
|
||||
{
|
||||
caller = Bukkit.getPlayer(args[0]);
|
||||
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true));
|
||||
}
|
||||
if(args.length >= 2)
|
||||
{
|
||||
_plugin.addPendingExplosion(caller, args[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.BonusGui;
|
||||
|
||||
public class GuiCommand extends CommandBase<BonusManager>{
|
||||
|
||||
public GuiCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "bonus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager()).openInventory();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TicketCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
public TicketCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "ticket");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Carl", "Missing Args: " + F.elem("/ticket <player> <amount>")));
|
||||
return;
|
||||
}
|
||||
|
||||
final String targetName = args[0];
|
||||
final String ticketString = args[1];
|
||||
Player target = UtilPlayer.searchExact(targetName);
|
||||
|
||||
|
||||
rewardTickets(caller, target, target.getName(), ticketString);
|
||||
}
|
||||
|
||||
private void rewardTickets(final Player caller, final Player target, final String targetName, String ticketString)
|
||||
{
|
||||
try
|
||||
{
|
||||
int tickets = Integer.parseInt(ticketString);
|
||||
Plugin.Get(target).setTickets(Plugin.Get(targetName).getTickets() + tickets);
|
||||
|
||||
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package mineplex.core.bonuses.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a player attempts to purchase a spin through carl
|
||||
*/
|
||||
public class CarlSpinnerEvent extends Event implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private boolean _cancelled;
|
||||
|
||||
public CarlSpinnerEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b)
|
||||
{
|
||||
_cancelled = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package mineplex.core.bonuses.gui;
|
||||
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.buttons.CarlSpinButton;
|
||||
import mineplex.core.bonuses.gui.buttons.DailyBonusButton;
|
||||
import mineplex.core.bonuses.gui.buttons.PollButton;
|
||||
import mineplex.core.bonuses.gui.buttons.RankBonusButton;
|
||||
import mineplex.core.bonuses.gui.buttons.VoteButton;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BonusGui extends SimpleGui
|
||||
{
|
||||
|
||||
private BonusManager manager;
|
||||
|
||||
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager)
|
||||
{
|
||||
super(plugin, player, player.getName() + "'s Bonuses", 5 * 9);
|
||||
|
||||
this.manager = manager;
|
||||
|
||||
setItem(10, new VoteButton(plugin, player, this, manager));
|
||||
|
||||
setItem(12, new RankBonusButton(getPlugin(), player, this, manager));
|
||||
|
||||
setItem(14, new DailyBonusButton(getPlugin(), player, this, manager));
|
||||
|
||||
setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager));
|
||||
|
||||
setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
System.err.println("Deleting the MailboxGui!");
|
||||
super.finalize();
|
||||
}
|
||||
}
|
281
Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java
Normal file
281
Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java
Normal file
@ -0,0 +1,281 @@
|
||||
package mineplex.core.bonuses.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gui.DisplayItem;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.buttons.RewardButton;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class SpinGui extends SimpleGui
|
||||
{
|
||||
private static final int HOPPER_SLOT = 4;
|
||||
private static final int CARL_SLOT = 22;
|
||||
private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ };
|
||||
|
||||
private int _tickCount;
|
||||
private RewardData _rewardData;
|
||||
private Reward _reward;
|
||||
private BonusManager _manager;
|
||||
private int _currentRewardIndex;
|
||||
private int _ticksThisSwap;
|
||||
private int _ticksPerSwap;
|
||||
private int _swapCount;
|
||||
private Reward[] _rewards;
|
||||
private boolean _stopped;
|
||||
private boolean _rewarded;
|
||||
private ArrayList<Integer> _ticks;
|
||||
private int _frame;
|
||||
private float _pitch;
|
||||
private int _stopSpinnerAt;
|
||||
|
||||
public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager)
|
||||
{
|
||||
super(plugin, player, "Carl's Spinner", 27);
|
||||
|
||||
_manager = manager;
|
||||
|
||||
ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false);
|
||||
|
||||
setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER)));
|
||||
//setItem(CARL_SLOT, new DisplayItem(carlItem));
|
||||
|
||||
|
||||
_ticks = new ArrayList<>();
|
||||
_frame = 0;
|
||||
_pitch = 1;
|
||||
|
||||
|
||||
|
||||
_ticksPerSwap = 1;
|
||||
|
||||
for (int i=0 ; i<40 ; i++)
|
||||
_ticks.add(1);
|
||||
|
||||
for (int i=0 ; i<20 ; i++)
|
||||
_ticks.add(2);
|
||||
|
||||
for (int i=0 ; i<10 ; i++)
|
||||
_ticks.add(4);
|
||||
|
||||
for (int i=0 ; i<4 ; i++)
|
||||
_ticks.add(6);
|
||||
|
||||
for (int i=0 ; i<3 ; i++)
|
||||
_ticks.add(8);
|
||||
|
||||
if (Math.random() > 0.5)
|
||||
{
|
||||
_ticks.add(12);
|
||||
}
|
||||
|
||||
_stopSpinnerAt = _ticks.size();
|
||||
|
||||
//Create Rewards
|
||||
_rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still.
|
||||
for (int i = 0; i < _stopSpinnerAt+10 ; i++)
|
||||
{
|
||||
if (i != _stopSpinnerAt + 4)
|
||||
{
|
||||
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerFiller, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerReal, true);
|
||||
_reward = _rewards[i];
|
||||
}
|
||||
}
|
||||
|
||||
_rewardData = _reward.giveReward("Carls Spinner", getPlayer());
|
||||
}
|
||||
|
||||
private void tick()
|
||||
{
|
||||
|
||||
if(_stopped)
|
||||
return;
|
||||
|
||||
_ticksThisSwap++;
|
||||
|
||||
// Swap
|
||||
if (_ticksThisSwap >= _ticksPerSwap)
|
||||
{
|
||||
_ticksThisSwap = 0;
|
||||
_swapCount++;
|
||||
|
||||
if(_pitch == 1)
|
||||
_pitch = (float) 1.5;
|
||||
else if(_pitch == 1.5)
|
||||
_pitch = 2;
|
||||
else if(_pitch == 2)
|
||||
_pitch = 1;
|
||||
|
||||
getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch);
|
||||
|
||||
_currentRewardIndex++;
|
||||
|
||||
updateGui();
|
||||
|
||||
// Slow
|
||||
_ticksPerSwap = _ticks.get(_currentRewardIndex - 1);
|
||||
|
||||
if(_currentRewardIndex == _stopSpinnerAt)
|
||||
_stopped = true;
|
||||
|
||||
}
|
||||
|
||||
_tickCount++;
|
||||
}
|
||||
|
||||
public void updateGui()
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
int index = _currentRewardIndex + i;
|
||||
|
||||
int slot = 9 + i;
|
||||
RewardData data = _rewards[index].getFakeRewardData(getPlayer());
|
||||
setItem(slot, new RewardButton(data));
|
||||
|
||||
// Glass Panes
|
||||
for (int j = 0; j < LINE_NUMS.length; j++)
|
||||
{
|
||||
int paneSlot = slot + LINE_NUMS[j];
|
||||
if (paneSlot == HOPPER_SLOT)
|
||||
continue;
|
||||
|
||||
setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
tick();
|
||||
checkIfDone();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void close(InventoryCloseEvent event)
|
||||
{
|
||||
if(_rewarded)
|
||||
return;
|
||||
|
||||
if(event.getPlayer() != getPlayer())
|
||||
return;
|
||||
|
||||
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||
|
||||
if (_reward.getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
else if (_reward.getRarity() == RewardRarity.LEGENDARY)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
else if (_reward.getRarity() == RewardRarity.MYTHICAL)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Glass(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if(!_stopped)
|
||||
return;
|
||||
|
||||
if(!_rewarded)
|
||||
return;
|
||||
|
||||
if(_frame == 0)
|
||||
{
|
||||
setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
_frame++;
|
||||
}
|
||||
else if(_frame < 5)
|
||||
{
|
||||
setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
|
||||
setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
|
||||
setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
_frame++;
|
||||
}
|
||||
if(_frame == 6)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfDone()
|
||||
{
|
||||
if(!_stopped)
|
||||
return;
|
||||
|
||||
if(_rewarded)
|
||||
return;
|
||||
|
||||
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||
if (_reward.getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
else if (_reward.getRarity() == RewardRarity.LEGENDARY)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
else if (_reward.getRarity() == RewardRarity.MYTHICAL)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
ItemStack item = getInventory().getItem(13);
|
||||
getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName()));
|
||||
_rewarded = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.plugin.Plugin;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
|
||||
public class CarlSpinButton implements GuiItem
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private Player _player;
|
||||
private BonusManager _bonusManager;
|
||||
private RewardManager _rewardManager;
|
||||
|
||||
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_player = player;
|
||||
_bonusManager = bonusManager;
|
||||
_rewardManager = rewardManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
BonusClientData client = _bonusManager.Get(_player);
|
||||
int tickets = client.getTickets();
|
||||
|
||||
if (tickets > 0)
|
||||
{
|
||||
_bonusManager.attemptCarlSpin(_player);
|
||||
}
|
||||
|
||||
// new SpinGui(_plugin, _player, _rewardManager).openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
BonusClientData client = _bonusManager.Get(_player);
|
||||
int tickets = client.getTickets();
|
||||
|
||||
String name = (tickets > 0 ? C.cGreen : C.cRed) + C.Bold + "Carl's Spinner";
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
Material material = Material.SKULL_ITEM;
|
||||
byte data = (byte) 4;
|
||||
|
||||
lore.add(" ");
|
||||
if (tickets > 0)
|
||||
{
|
||||
lore.add(ChatColor.RESET + "Click to Spin");
|
||||
}
|
||||
else
|
||||
{
|
||||
lore.add(ChatColor.RESET + "You need a Carl Spin Ticket to Spin");
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.YELLOW + "Your Tickets: " + C.cWhite + tickets);
|
||||
|
||||
return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.gui.ItemRefresher;
|
||||
import mineplex.core.gui.pages.LoadingWindow;
|
||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.StreakRecord;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class DailyBonusButton implements GuiItem, Listener
|
||||
{
|
||||
|
||||
private ItemStack _item;
|
||||
|
||||
private Player _player;
|
||||
private Plugin _plugin;
|
||||
private ItemRefresher _gui;
|
||||
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public DailyBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||
{
|
||||
this._bonusManager = bonusManager;
|
||||
this._player = player;
|
||||
this._plugin = plugin;
|
||||
this._gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||
setItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
if (isAvailable()) {
|
||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||
refreshItem();
|
||||
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||
_bonusManager.attemptDailyBonus(getPlayer(), _bonusManager.getDailyBonusAmount(_player), new Callback<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean t)
|
||||
{
|
||||
if (t) {
|
||||
|
||||
setItem();
|
||||
|
||||
if (getPlayer().getOpenInventory() != null) {
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6*9, 20*3, getGui()).openInventory();
|
||||
} else {
|
||||
UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!"));
|
||||
}
|
||||
_bonusManager.addPendingExplosion(getPlayer(), "DAILY");
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
} else {
|
||||
if (getPlayer().getOpenInventory() != null) {
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6*9, 20*3, getGui()).openInventory();
|
||||
} else {
|
||||
UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!"));
|
||||
}
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
|
||||
}
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
});
|
||||
} else
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!event.getType().equals(UpdateType.SEC))
|
||||
return;
|
||||
// refreshItem(); // Todo Unnecessary?
|
||||
}
|
||||
|
||||
private void setItem()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
Material material;
|
||||
String itemName;
|
||||
byte data = 0;
|
||||
|
||||
if (isAvailable())
|
||||
{
|
||||
material = Material.CHEST;
|
||||
itemName = C.cGreen + C.Bold + "Daily Reward";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + C.Bold + "Daily Reward";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
|
||||
BonusClientData client = _bonusManager.Get(_player);
|
||||
|
||||
BonusAmount bonusAmount = _bonusManager.getDailyBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
lore.add(" ");
|
||||
|
||||
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getDailyStreak());
|
||||
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + _bonusManager.getDailyMultiplier(_player) + "%");
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak());
|
||||
|
||||
if (client.getDailyTime() != null)
|
||||
{
|
||||
long lastBonus = _bonusManager.getLocalTime(client.getDailyTime().getTime());
|
||||
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.STREAK_RESET_TIME);
|
||||
|
||||
if (timeLeft > 0)
|
||||
{
|
||||
lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT));
|
||||
}
|
||||
}
|
||||
|
||||
StreakRecord streakRecord = _bonusManager.getDailyStreak();
|
||||
if (streakRecord != null)
|
||||
{
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
|
||||
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
|
||||
}
|
||||
|
||||
|
||||
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public void refreshItem()
|
||||
{
|
||||
getGui().refreshItem(this);
|
||||
}
|
||||
|
||||
public long timeLeft()
|
||||
{
|
||||
long timeLeft = _bonusManager.nextDailyBonus(getPlayer()) - System.currentTimeMillis();
|
||||
return timeLeft;
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return (timeLeft() <= 0);
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public ItemRefresher getGui()
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gui.GuiInventory;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.gui.SimpleGuiItem;
|
||||
import mineplex.core.gui.botton.BackBotton;
|
||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.poll.Poll;
|
||||
import mineplex.core.poll.PollManager;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
protected boolean _create;
|
||||
|
||||
private PollManager _pollManager;
|
||||
private BonusManager _bonusManager;
|
||||
private CoreClientManager _clientManager;
|
||||
private GuiInventory _master;
|
||||
|
||||
private HashMap<Integer, GuiItem> hard = new HashMap<Integer, GuiItem>();
|
||||
|
||||
private Poll _poll;
|
||||
|
||||
public PollButton(Plugin plugin, Player player, PollManager pollManager, CoreClientManager clientManager, GuiInventory master, BonusManager bonusManager)
|
||||
{
|
||||
super(plugin, player, "Poll:", 6 * 9);
|
||||
this._create = true;
|
||||
this._master = master;
|
||||
this._clientManager = clientManager;
|
||||
this._pollManager = pollManager;
|
||||
hard.put(0, new BackBotton(master));
|
||||
_bonusManager = bonusManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
if (_create)
|
||||
{
|
||||
this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank());
|
||||
|
||||
if (_poll != null)
|
||||
{
|
||||
|
||||
setItem(13, getQuestionItem(_poll.getQuestion()));
|
||||
|
||||
int[] slots = even(9, _poll.getAnswers().length);
|
||||
|
||||
for (int i = 0; i < slots.length; i++)
|
||||
{
|
||||
AnswerItem item = new AnswerItem(_poll, i);
|
||||
setItem(9 * 3 + slots[i], item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
if (_poll == null)
|
||||
{
|
||||
lore.add("");
|
||||
lore.add(C.cWhite + "You've voted on all of the polls!");
|
||||
return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + C.Bold + "Vote on Poll", lore);
|
||||
}
|
||||
else
|
||||
{
|
||||
lore.add("");
|
||||
lore.add(C.cWhite + _poll.getQuestion());
|
||||
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 ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
if (_poll == null)
|
||||
{
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f);
|
||||
}
|
||||
else
|
||||
{
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
openInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public GuiItem getQuestionItem(String question)
|
||||
{
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
for (String string : wrap(question))
|
||||
lore.add(C.cWhite + string);
|
||||
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");
|
||||
|
||||
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)
|
||||
{
|
||||
return UtilText.wrap(text, 40);
|
||||
}
|
||||
|
||||
public static int[] even(int size, int amount)
|
||||
{
|
||||
int[] list = new int[amount];
|
||||
|
||||
float interval = (size / amount);
|
||||
float offset = -(interval / 2);
|
||||
|
||||
for (int i = 1; i <= amount; i++)
|
||||
{
|
||||
list[i - 1] = (int) (Math.ceil(i * interval) + offset);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Poll getPoll()
|
||||
{
|
||||
return _poll;
|
||||
}
|
||||
|
||||
public GuiInventory getMaster()
|
||||
{
|
||||
return _master;
|
||||
}
|
||||
|
||||
private class AnswerItem implements GuiItem
|
||||
{
|
||||
|
||||
private int num;
|
||||
|
||||
private AnswerItem(Poll poll, int num)
|
||||
{
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add(C.cWhite + getPoll().getAnswers()[num]);
|
||||
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
_create = true;
|
||||
|
||||
_pollManager.answerPoll(getPlayer(), _poll, num);
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory();
|
||||
_bonusManager.addPendingExplosion(getPlayer(), "POLL");
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
}
|
@ -0,0 +1,230 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.gui.ItemRefresher;
|
||||
import mineplex.core.gui.pages.LoadingWindow;
|
||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class RankBonusButton implements GuiItem, Listener {
|
||||
|
||||
private boolean hasRank;
|
||||
|
||||
private ItemStack _item;
|
||||
|
||||
private Player _player;
|
||||
private Plugin _plugin;
|
||||
private ItemRefresher _gui;
|
||||
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public RankBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||
{
|
||||
this._bonusManager = bonusManager;
|
||||
this._player = player;
|
||||
this._plugin = plugin;
|
||||
this._gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
if (_bonusManager.getRankBonusAmount(getPlayer()).isGreaterThanZero())
|
||||
{
|
||||
this.hasRank = true;
|
||||
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hasRank = false;
|
||||
}
|
||||
|
||||
setItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
if (isAvailable()) {
|
||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||
refreshItem();
|
||||
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||
_bonusManager.attemptRankBonus(getPlayer(), new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean t)
|
||||
{
|
||||
setItem();
|
||||
|
||||
if (t)
|
||||
{
|
||||
if (getPlayer().getOpenInventory() != null)
|
||||
{
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6 * 9, 20 * 3, getGui()).openInventory();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!"));
|
||||
}
|
||||
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getPlayer().getOpenInventory() != null)
|
||||
{
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6 * 9, 20 * 3, getGui()).openInventory();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!"));
|
||||
}
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
|
||||
}
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
});
|
||||
} else
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!event.getType().equals(UpdateType.SEC))
|
||||
return;
|
||||
// refreshItem(); // Todo Unnecessary?
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
private void setItem()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
Material material;
|
||||
String itemName;
|
||||
byte data = 0;
|
||||
|
||||
if (!hasRank)
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
|
||||
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.WHITE + "Purchase a Rank at;");
|
||||
lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isAvailable())
|
||||
{
|
||||
material = Material.ENDER_CHEST;
|
||||
itemName = C.cGreen + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name);
|
||||
BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
}
|
||||
|
||||
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
|
||||
public void refreshItem()
|
||||
{
|
||||
_gui.refreshItem(this);
|
||||
}
|
||||
|
||||
public long timeLeft()
|
||||
{
|
||||
return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
{
|
||||
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(), "----------------------------------------");
|
||||
|
||||
getPlayer().closeInventory();
|
||||
return false;
|
||||
}
|
||||
return (timeLeft() <= 0);
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public ItemRefresher getGui()
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.reward.RewardData;
|
||||
|
||||
public class RewardButton implements GuiItem
|
||||
{
|
||||
private RewardData _data;
|
||||
|
||||
public RewardButton(RewardData data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ItemStack stack = _data.getDisplayItem();
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(_data.getFriendlyName());
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.gui.ItemRefresher;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.StreakRecord;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class VoteButton implements GuiItem, Listener {
|
||||
|
||||
private ItemStack _item;
|
||||
|
||||
private String _url;
|
||||
|
||||
private Player _player;
|
||||
private Plugin _plugin;
|
||||
private ItemRefresher _gui;
|
||||
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||
{
|
||||
this._bonusManager = bonusManager;
|
||||
this._player = player;
|
||||
this._plugin = plugin;
|
||||
this._gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
//TODO get url from db
|
||||
_url = "http://minecraftservers.org/vote/121070";
|
||||
|
||||
setItem();
|
||||
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
if (isAvailable())
|
||||
{
|
||||
getPlayer().closeInventory();
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
|
||||
UtilPlayer.message(getPlayer(), "----------------------------------------");
|
||||
UtilPlayer.message(getPlayer(), "");
|
||||
|
||||
new JsonMessage("Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
|
||||
new JsonMessage(C.cGreen + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
|
||||
|
||||
UtilPlayer.message(getPlayer(), "");
|
||||
UtilPlayer.message(getPlayer(), "----------------------------------------");
|
||||
|
||||
|
||||
|
||||
getPlayer().closeInventory();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
private void setItem()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
Material material;
|
||||
String itemName;
|
||||
byte data = 0;
|
||||
|
||||
if (isAvailable())
|
||||
{
|
||||
material = Material.JUKEBOX;
|
||||
itemName = C.cGreen + C.Bold + "Vote for Mineplex";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click to Vote!");
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + C.Bold + "Vote for Mineplex";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Next vote in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
|
||||
BonusClientData client = _bonusManager.Get(_player);
|
||||
|
||||
BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
lore.add(" ");
|
||||
|
||||
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
|
||||
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(client) + "%");
|
||||
if (client.getVoteTime() != null)
|
||||
{
|
||||
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
|
||||
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.STREAK_RESET_TIME);
|
||||
|
||||
if (timeLeft > 0)
|
||||
{
|
||||
lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT));
|
||||
}
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
|
||||
|
||||
StreakRecord streakRecord = _bonusManager.getVoteStreak();
|
||||
if (streakRecord != null)
|
||||
{
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
|
||||
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
|
||||
}
|
||||
|
||||
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
|
||||
public long timeLeft()
|
||||
{
|
||||
return _bonusManager.nextVoteTime(getPlayer()) - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
{
|
||||
if (_url == null)
|
||||
return false;
|
||||
System.out.println(timeLeft());
|
||||
|
||||
return (timeLeft() <= 0);
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public ItemRefresher getGui()
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
}
|
@ -13,6 +13,9 @@ import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.column.Column;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -62,6 +65,11 @@ public abstract class RepositoryBase implements Listener
|
||||
return _dataSource;
|
||||
}
|
||||
|
||||
protected DSLContext jooq()
|
||||
{
|
||||
return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool!
|
||||
* @see Connection#close()
|
||||
|
@ -92,7 +92,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new ItemTNT(this));
|
||||
addGadget(new ItemMelonLauncher(this));
|
||||
addGadget(new ItemFleshHook(this));
|
||||
//addGadget(new ItemPaintballGun(this));
|
||||
addGadget(new ItemPaintballGun(this));
|
||||
addGadget(new ItemBatGun(this));
|
||||
addGadget(new ItemCoinBomb(this));
|
||||
addGadget(new ItemPaintbrush(this));
|
||||
|
@ -61,45 +61,6 @@ public class ItemPaintballGun extends ItemGadget
|
||||
|
||||
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity());
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 49);
|
||||
|
||||
byte color = 2;
|
||||
double r = Math.random();
|
||||
if (r > 0.8) color = 4;
|
||||
else if (r > 0.6) color = 5;
|
||||
else if (r > 0.4) color = 9;
|
||||
else if (r > 0.2) color = 14;
|
||||
|
||||
for (Block block : UtilBlock.getInRadius(loc, 3d).keySet())
|
||||
{
|
||||
if (block.getType() == Material.PORTAL)
|
||||
return;
|
||||
|
||||
if (block.getType() == Material.CACTUS)
|
||||
return;
|
||||
|
||||
if (block.getType() == Material.SUGAR_CANE_BLOCK)
|
||||
return;
|
||||
}
|
||||
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
blocks.addAll(UtilBlock.getInRadius(loc, 1.5d).keySet());
|
||||
|
||||
GadgetBlockEvent gadgetEvent = new GadgetBlockEvent(this, blocks);
|
||||
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
||||
|
||||
if (gadgetEvent.isCancelled())
|
||||
return;
|
||||
|
||||
for (Block block : gadgetEvent.getBlocks())
|
||||
{
|
||||
if (!UtilBlock.solid(block))
|
||||
continue;
|
||||
|
||||
if (block.getType() == Material.CARPET)
|
||||
Manager.getBlockRestore().Add(block, 171, color, 4000);
|
||||
else
|
||||
Manager.getBlockRestore().Add(block, 35, color, 4000);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public interface ClickExecutor
|
||||
{
|
||||
public void click(ClickType clickType);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
public interface Container<T> {
|
||||
public T getObject();
|
||||
}
|
40
Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java
Normal file
40
Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java
Normal file
@ -0,0 +1,40 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.gui.GuiItem;
|
||||
|
||||
public class DisplayItem implements GuiItem
|
||||
{
|
||||
private ItemStack _item;
|
||||
|
||||
public DisplayItem(ItemStack item)
|
||||
{
|
||||
_item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
|
||||
public interface GuiInventory {
|
||||
public void openInventory();
|
||||
public Inventory getInventory();
|
||||
}
|
9
Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java
Normal file
9
Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java
Normal file
@ -0,0 +1,9 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface GuiItem extends ClickExecutor, Container<ItemStack>
|
||||
{
|
||||
public void setup();
|
||||
public void close();
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
public interface ItemRefresher extends GuiInventory
|
||||
{
|
||||
public void refreshItem(GuiItem item);
|
||||
}
|
241
Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java
Normal file
241
Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java
Normal file
@ -0,0 +1,241 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class SimpleGui implements ItemRefresher, Listener
|
||||
{
|
||||
// private Map<Integer, GuiItem> _buttonMap = new HashMap<Integer, GuiItem>();
|
||||
private GuiItem[] _items;
|
||||
|
||||
private Player _player;
|
||||
private Plugin _plugin;
|
||||
private int _size;
|
||||
private String _title;
|
||||
private Inventory _inv;
|
||||
|
||||
public SimpleGui(Plugin plugin, Player player)
|
||||
{
|
||||
this(plugin, player, null, 0);
|
||||
}
|
||||
|
||||
public SimpleGui(Plugin plugin, Player player, int size)
|
||||
{
|
||||
this(plugin, player, null, size);
|
||||
}
|
||||
|
||||
public SimpleGui(Plugin plugin, Player player, String title)
|
||||
{
|
||||
this(plugin, player, title, 0);
|
||||
}
|
||||
|
||||
public SimpleGui(Plugin plugin, Player player, String title, int size)
|
||||
{
|
||||
|
||||
Validate.notNull(plugin, "The plugin cannot be null!");
|
||||
Validate.notNull(player, "The player cannot be null!");
|
||||
|
||||
this._plugin = plugin;
|
||||
this._player = player;
|
||||
|
||||
if (size == 0)
|
||||
setSize(9);
|
||||
else
|
||||
setSize(size);
|
||||
|
||||
if (title == null)
|
||||
setTitle(" ");
|
||||
else
|
||||
setTitle(title);
|
||||
|
||||
updateArray();
|
||||
|
||||
_inv = createInventory();
|
||||
refreshInventory();
|
||||
}
|
||||
|
||||
private void updateArray()
|
||||
{
|
||||
_items = new GuiItem[_size];
|
||||
}
|
||||
|
||||
public void setItem(int i, GuiItem item)
|
||||
{
|
||||
Validate.isTrue(i >= 0 && i < _size, "Tried to add a gui item outside of inventory range");
|
||||
|
||||
GuiItem oldItem = getItem(i);
|
||||
if (oldItem != null) oldItem.close();
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
_items[i] = item;
|
||||
item.setup();
|
||||
}
|
||||
|
||||
refreshItem(i);
|
||||
}
|
||||
|
||||
public GuiItem getItem(int i)
|
||||
{
|
||||
return _items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
refreshInventory();
|
||||
UtilPlayer.swapToInventory(_player, _inv);
|
||||
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||
}
|
||||
|
||||
public Inventory createInventory()
|
||||
{
|
||||
Inventory inv = Bukkit.createInventory(_player, getSize(), getTitle());
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void refreshInventory()
|
||||
{
|
||||
for (int i = 0; i < _size; i++)
|
||||
{
|
||||
refreshItem(i);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (!event.getWhoClicked().equals(_player) || !event.getInventory().equals(_inv))
|
||||
return;
|
||||
|
||||
if (event.getSlot() >= 0 && event.getSlot() < _size)
|
||||
{
|
||||
GuiItem item = getItem(event.getSlot());
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
item.click(event.getClick());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if (!event.getPlayer().equals(_player))
|
||||
return;
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClose(InventoryCloseEvent event)
|
||||
{
|
||||
if (!event.getPlayer().equals(_player))
|
||||
return;
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void quit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!event.getPlayer().equals(_player))
|
||||
return;
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
private void close()
|
||||
{
|
||||
// _inv = null; // TODO - do we really need to null the inventory?
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
for (int i = 0; i < _size; i++)
|
||||
{
|
||||
GuiItem item = getItem(i);
|
||||
if (item != null) item.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void refreshItem(GuiItem item)
|
||||
{
|
||||
if (_inv == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _size; i++)
|
||||
{
|
||||
if (item.equals(getItem(i)))
|
||||
refreshItem(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshItem(int slot)
|
||||
{
|
||||
GuiItem gi = getItem(slot);
|
||||
|
||||
ItemStack itemStack = null;
|
||||
if (gi != null) itemStack = gi.getObject();
|
||||
|
||||
_inv.setItem(slot, itemStack);
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this._title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory()
|
||||
{
|
||||
return _inv;
|
||||
}
|
||||
|
||||
public void setSize(int size)
|
||||
{
|
||||
Validate.isTrue(size % 9 == 0, "The size " + size + " is not divisible by 9");
|
||||
this._size = size;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package mineplex.core.gui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SimpleGuiItem extends ItemStack implements GuiItem {
|
||||
|
||||
public SimpleGuiItem(Material type, int amount, short damage)
|
||||
{
|
||||
super(type, amount, damage);
|
||||
}
|
||||
|
||||
public SimpleGuiItem(Material type, int amount)
|
||||
{
|
||||
super(type, amount);
|
||||
}
|
||||
|
||||
public SimpleGuiItem(Material type)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
public SimpleGuiItem(ItemStack itemStack)
|
||||
{
|
||||
super(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package mineplex.core.gui.botton;
|
||||
|
||||
import mineplex.core.gui.GuiInventory;
|
||||
import mineplex.core.gui.SimpleGuiItem;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BackBotton extends SimpleGuiItem {
|
||||
|
||||
private GuiInventory _gui;
|
||||
|
||||
public BackBotton(GuiInventory gui) {
|
||||
this(ItemStackFactory.Instance.CreateStack(Material.BED, (byte) 0, 1, ChatColor.DARK_GRAY + "<-- Go Back"), gui);
|
||||
}
|
||||
|
||||
public BackBotton(ItemStack itemStack, GuiInventory gui)
|
||||
{
|
||||
super(itemStack);
|
||||
this._gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
getGui().openInventory();
|
||||
}
|
||||
|
||||
public GuiInventory getGui()
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
}
|
@ -0,0 +1,238 @@
|
||||
package mineplex.core.gui.pages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class LoadingWindow implements Runnable, Listener {
|
||||
|
||||
public static String[] messages = new String[]{"Sending Carrier Pigeons...", "#BlameChiss", "Converting to Morse Code...", "Training monkeys..."};
|
||||
public static long defaultWait = 30;
|
||||
|
||||
public ItemStack _background;
|
||||
public ItemStack _barLoading;
|
||||
public ItemStack _barBack;
|
||||
|
||||
private Inventory _inv;
|
||||
private final InventoryView _currentInventory;
|
||||
|
||||
private final int _id;
|
||||
|
||||
private final Plugin _plugin;
|
||||
private final UUID _playersUUID;
|
||||
|
||||
private String _message;
|
||||
private String _title;
|
||||
|
||||
private final int _size;
|
||||
|
||||
private final int[] _activeRows;
|
||||
|
||||
private long _ticker = 0;
|
||||
|
||||
public LoadingWindow(Plugin plugin, Player player, int size) {
|
||||
this(plugin, player, null, size, null, null);
|
||||
}
|
||||
|
||||
public LoadingWindow(Plugin plugin, Player player, long startTime, int size) {
|
||||
this(plugin, player, startTime, size, null, null);
|
||||
}
|
||||
|
||||
public LoadingWindow(Plugin plugin, Player player, long startTime, int size, String message)
|
||||
{
|
||||
this(plugin, player, startTime, size, message, message);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public LoadingWindow(Plugin plugin, Player player, Long startTime, int size, String title, String message)
|
||||
{
|
||||
Validate.notNull(plugin, "The plugin can not be null!");
|
||||
Validate.notNull(player, "The player can not be null!");
|
||||
|
||||
_currentInventory = player.getOpenInventory();
|
||||
|
||||
_size = size;
|
||||
_activeRows = getActiveRows(size / 9);
|
||||
|
||||
_plugin = plugin;
|
||||
_playersUUID = player.getUniqueId();
|
||||
|
||||
|
||||
_background = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData(), 1, _message);
|
||||
_barLoading = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, _message);
|
||||
_barBack = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.WHITE.getData(), 1, _message);
|
||||
|
||||
|
||||
if (title == null && message == null)
|
||||
{
|
||||
String randomName = UtilMath.randomElement(messages);
|
||||
title = randomName;
|
||||
message = randomName;
|
||||
}
|
||||
else if (title == null)
|
||||
{
|
||||
title = " ";
|
||||
}
|
||||
else if (message == null)
|
||||
{
|
||||
message = UtilMath.randomElement(messages);
|
||||
}
|
||||
if (startTime == null)
|
||||
startTime = defaultWait;
|
||||
|
||||
|
||||
_title = title;
|
||||
setMessage(message);
|
||||
_id = Bukkit.getScheduler().runTaskTimer(plugin, this, startTime, 5).getTaskId();
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
_message = message;
|
||||
ItemMeta im =_background.getItemMeta();
|
||||
im.setDisplayName(_message);
|
||||
_background.setItemMeta(im);
|
||||
_barBack.setItemMeta(im);
|
||||
_barLoading.setItemMeta(im);
|
||||
|
||||
setBackGround();
|
||||
setLoadingBarItems();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
_title = title;
|
||||
|
||||
Player player = Bukkit.getPlayer(_playersUUID);
|
||||
if (_inv == null || player == null)
|
||||
return;
|
||||
|
||||
ItemStack[] con = _inv.getContents();
|
||||
|
||||
_inv = Bukkit.createInventory(null, _size, _title);
|
||||
_inv.setContents(con);
|
||||
UtilPlayer.swapToInventory(player, _inv);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent event) {
|
||||
if (event.getWhoClicked().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClose(InventoryCloseEvent event) {
|
||||
if (event.getPlayer().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) {
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Player player = Bukkit.getPlayer(_playersUUID);
|
||||
|
||||
if (player == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) {
|
||||
end();
|
||||
return;
|
||||
}
|
||||
if (_inv == null) {
|
||||
_inv = Bukkit.createInventory(null, _size, _title);
|
||||
|
||||
setBackGround();
|
||||
setLoadingBarItems();
|
||||
UtilPlayer.swapToInventory(player, _inv);
|
||||
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||
} else
|
||||
setLoadingBarItems();
|
||||
|
||||
_ticker++;
|
||||
}
|
||||
|
||||
public void end() {
|
||||
HandlerList.unregisterAll(this);
|
||||
Bukkit.getScheduler().cancelTask(_id);
|
||||
_inv = null;
|
||||
}
|
||||
|
||||
private void setBackGround() {
|
||||
if (_inv == null)
|
||||
return;
|
||||
|
||||
List<Integer> ignore = new ArrayList<Integer>();
|
||||
|
||||
for (int row : _activeRows) {
|
||||
|
||||
int rowStart = row * 9;
|
||||
int rowEnd = rowStart + 9;
|
||||
|
||||
for (int i = rowStart; i < rowEnd; i++) {
|
||||
ignore.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _size; i++) {
|
||||
if (!ignore.contains(i))
|
||||
_inv.setItem(i, _background);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLoadingBarItems() {
|
||||
if (_inv == null)
|
||||
return;
|
||||
ItemStack[] loadingBar = getLoadingBar();
|
||||
|
||||
for (int row : _activeRows) {
|
||||
int rowStart = row * 9;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
_inv.setItem(i + rowStart, loadingBar[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack[] getLoadingBar()
|
||||
{
|
||||
ItemStack[] loadingBar = new ItemStack[9];
|
||||
|
||||
int barStart = (int) (_ticker % 9);
|
||||
int barEnd = (barStart + 3) % 9;
|
||||
|
||||
boolean endAfter = barEnd > barStart;
|
||||
|
||||
for (int i = 0; i < loadingBar.length; i++) {
|
||||
if (endAfter ? (i >= barStart && i < barEnd) : (i >= barStart || i < barEnd))
|
||||
loadingBar[i] = _barLoading;
|
||||
else
|
||||
loadingBar[i] = _barBack;
|
||||
}
|
||||
return loadingBar;
|
||||
}
|
||||
|
||||
private static int[] getActiveRows(int rows)
|
||||
{
|
||||
float mid = rows / 2.0f;
|
||||
if (mid == (int) mid)
|
||||
return new int[] { (int) mid , (int) mid -1};
|
||||
else
|
||||
return new int[] { (int) Math.floor(mid)};
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package mineplex.core.gui.pages;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gui.GuiInventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class MessageWindow implements Listener, GuiInventory {
|
||||
|
||||
private UUID _playersUUID;
|
||||
private Plugin _plugin;
|
||||
private Inventory _inv;
|
||||
|
||||
public MessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
this._playersUUID = player.getUniqueId();
|
||||
|
||||
_inv = Bukkit.createInventory(null, size, title);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
_inv.setItem(i, is);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onClick(InventoryClickEvent e)
|
||||
{
|
||||
if (!e.getWhoClicked().getUniqueId().equals(_playersUUID))
|
||||
return;
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent e)
|
||||
{
|
||||
if (!e.getPlayer().getUniqueId().equals(_playersUUID))
|
||||
return;
|
||||
HandlerList.unregisterAll(this);
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
Player player = Bukkit.getPlayer(_playersUUID);
|
||||
|
||||
if (player == null || player.getOpenInventory().getTopInventory().equals(_inv))
|
||||
return;
|
||||
|
||||
UtilPlayer.swapToInventory(player, _inv);
|
||||
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||
open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory()
|
||||
{
|
||||
return _inv;
|
||||
}
|
||||
public UUID getPlayersUUID()
|
||||
{
|
||||
return _playersUUID;
|
||||
}
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
public void open() {
|
||||
|
||||
}
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package mineplex.core.gui.pages;
|
||||
|
||||
import mineplex.core.gui.GuiInventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TimedMessageWindow extends MessageWindow implements Runnable {
|
||||
private GuiInventory _gui;
|
||||
private int _id;
|
||||
private long _time;
|
||||
|
||||
public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time)
|
||||
{
|
||||
this(plugin, player, is, title, size, time, null);
|
||||
}
|
||||
|
||||
public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time, GuiInventory gui)
|
||||
{
|
||||
super(plugin, player, is, title, size);
|
||||
|
||||
this._gui = gui;
|
||||
this._time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e)
|
||||
{
|
||||
super.onClick(e);
|
||||
if (e.isCancelled() && _gui != null && (e.getWhoClicked() instanceof Player)) {
|
||||
_gui.openInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open()
|
||||
{
|
||||
this._id = Bukkit.getScheduler().runTaskLater(getPlugin(), this, _time).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
Bukkit.getScheduler().cancelTask(_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Player player = Bukkit.getPlayer(getPlayersUUID());
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (_gui != null) {
|
||||
_gui.openInventory();
|
||||
} else
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
}
|
@ -42,8 +42,8 @@ public class NotificationManager extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
// if (event.getType() == UpdateType.MIN_08)
|
||||
// hugeSale();
|
||||
if (event.getType() == UpdateType.MIN_08)
|
||||
hugeSale();
|
||||
|
||||
// if (event.getType() == UpdateType.MIN_16)
|
||||
// sale();
|
||||
@ -95,17 +95,17 @@ public class NotificationManager extends MiniPlugin
|
||||
if (rank == Rank.ALL)
|
||||
{
|
||||
UtilPlayer.message(player, C.cWhite + " " + player.getName() + ", you can get 75% Off " + C.cAqua + C.Bold + "All Lifetime Ranks" + C.cWhite + "!");
|
||||
UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!");
|
||||
UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!");
|
||||
}
|
||||
else if (rank == Rank.ULTRA)
|
||||
{
|
||||
UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for only $7.50!");
|
||||
UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!");
|
||||
UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!");
|
||||
}
|
||||
else if (rank == Rank.HERO)
|
||||
{
|
||||
UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for only $7.50!");
|
||||
UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!");
|
||||
UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!");
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, " ");
|
||||
|
@ -161,6 +161,17 @@ public class NpcManager extends MiniPlugin
|
||||
return _npcMap.get(uuid);
|
||||
}
|
||||
|
||||
public Npc getNpcByName(String name)
|
||||
{
|
||||
for (Npc npc : _npcs)
|
||||
{
|
||||
if (npc.getDatabaseRecord().getName() != null && npc.getDatabaseRecord().getName().contains(name))
|
||||
return npc;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Npc getNpcByEntity(Entity entity)
|
||||
{
|
||||
if (entity == null)
|
||||
|
@ -12,7 +12,7 @@ public class HostServerCommand extends CommandBase<PersonalServerManager>
|
||||
{
|
||||
public HostServerCommand(PersonalServerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.LEGEND, "hostserver");
|
||||
super(plugin, Rank.LEGEND, "hostserver", "mps");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,6 @@ public class PersonalServerManager extends MiniPlugin
|
||||
{
|
||||
if (_giveInterfaceItem)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.poll;
|
||||
package mineplex.core.poll;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.poll;
|
||||
package mineplex.core.poll;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
@ -1,6 +1,4 @@
|
||||
package mineplex.hub.poll;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
package mineplex.core.poll;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/16/2014.
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.poll;
|
||||
package mineplex.core.poll;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -23,9 +23,7 @@ import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.poll.command.PollCommand;
|
||||
import mineplex.core.poll.command.PollCommand;
|
||||
|
||||
public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
{
|
||||
@ -64,7 +62,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
pollData.setPollCooldown(5000);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/*@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
@ -88,7 +86,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
pollData.updatePollCooldown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public Poll getNextPoll(PlayerPollData pollData, Rank playerRank)
|
||||
{
|
||||
@ -101,6 +99,11 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasPoll(Player player)
|
||||
{
|
||||
return getNextPoll(Get(player), getClientManager().Get(player).GetRank()) != null;
|
||||
}
|
||||
|
||||
public void displayPoll(Player player, Poll poll)
|
||||
{
|
||||
String[] answers = poll.getAnswers();
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.poll;
|
||||
package mineplex.core.poll;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.poll;
|
||||
package mineplex.core.poll;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/26/2014.
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.poll.command;
|
||||
package mineplex.core.poll.command;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
@ -13,10 +13,10 @@ import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.poll.PlayerPollData;
|
||||
import mineplex.hub.poll.Poll;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.hub.poll.PollStats;
|
||||
import mineplex.core.poll.PlayerPollData;
|
||||
import mineplex.core.poll.Poll;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.core.poll.PollStats;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/17/2014.
|
@ -4,6 +4,19 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
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.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,18 +24,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
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>
|
||||
{
|
||||
private PreferencesRepository _repository;
|
||||
@ -53,6 +58,27 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
_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
|
||||
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)
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
|
@ -27,6 +27,8 @@ public abstract class Reward
|
||||
|
||||
protected abstract RewardData giveRewardCustom(Player player);
|
||||
|
||||
public abstract RewardData getFakeRewardData(Player player);
|
||||
|
||||
public abstract boolean canGiveReward(Player player);
|
||||
|
||||
public RewardRarity getRarity()
|
||||
|
@ -9,11 +9,13 @@ public class RewardData
|
||||
{
|
||||
private final String _friendlyName;
|
||||
private final ItemStack _displayItem;
|
||||
private final RewardRarity _rarity;
|
||||
|
||||
public RewardData(String friendlyName, ItemStack displayItem)
|
||||
public RewardData(String friendlyName, ItemStack displayItem, RewardRarity rarity)
|
||||
{
|
||||
_friendlyName = friendlyName;
|
||||
_displayItem = displayItem;
|
||||
_rarity = rarity;
|
||||
}
|
||||
|
||||
public String getFriendlyName()
|
||||
@ -26,4 +28,9 @@ public class RewardData
|
||||
return _displayItem;
|
||||
}
|
||||
|
||||
public RewardRarity getRarity()
|
||||
{
|
||||
return _rarity;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,10 +18,13 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.reward.rewards.CoinReward;
|
||||
import mineplex.core.reward.rewards.ExperienceReward;
|
||||
import mineplex.core.reward.rewards.GemReward;
|
||||
import mineplex.core.reward.rewards.InventoryReward;
|
||||
import mineplex.core.reward.rewards.PetReward;
|
||||
import mineplex.core.reward.rewards.RankReward;
|
||||
import mineplex.core.reward.rewards.UnknownPackageReward;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
|
||||
public class RewardManager
|
||||
@ -29,17 +32,18 @@ public class RewardManager
|
||||
private JavaPlugin _plugin;
|
||||
private HashMap<RewardRarity, List<Reward>> _treasureMap;
|
||||
private Random _random;
|
||||
private boolean _carlSpinner;
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private boolean _doubleGadgetValue;
|
||||
|
||||
public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager,
|
||||
int commonValueMin, int commonValueMax,
|
||||
int uncommonValueMin, int uncommonValueMax,
|
||||
int rareValueMin, int rareValueMax,
|
||||
int legendValueMin, int legendValueMax,
|
||||
boolean doubleGadgetValue)
|
||||
public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager,
|
||||
int commonValueMin, int commonValueMax,
|
||||
int uncommonValueMin, int uncommonValueMax,
|
||||
int rareValueMin, int rareValueMax,
|
||||
int legendValueMin, int legendValueMax,
|
||||
boolean doubleGadgetValue, boolean carlSpinner)
|
||||
{
|
||||
_plugin = donationManager.getPlugin();
|
||||
_treasureMap = new HashMap<RewardRarity, List<Reward>>();
|
||||
@ -53,19 +57,29 @@ public class RewardManager
|
||||
_clientManager = clientManager;
|
||||
|
||||
_doubleGadgetValue = doubleGadgetValue;
|
||||
_carlSpinner = carlSpinner;
|
||||
|
||||
addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax);
|
||||
addUncommon(donationManager, inventoryManager, petManager, uncommonValueMin, uncommonValueMax);
|
||||
addRare(donationManager, inventoryManager, petManager, rareValueMin, rareValueMax);
|
||||
addLegendary(donationManager, inventoryManager, petManager, legendValueMin, legendValueMax);
|
||||
addCommon(donationManager, inventoryManager, petManager, statsManager, commonValueMin, commonValueMax);
|
||||
addUncommon(donationManager, inventoryManager, petManager, statsManager, uncommonValueMin, uncommonValueMax);
|
||||
addRare(donationManager, inventoryManager, petManager, statsManager, rareValueMin, rareValueMax);
|
||||
addLegendary(donationManager, inventoryManager, petManager, statsManager, legendValueMin, legendValueMax);
|
||||
}
|
||||
|
||||
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
|
||||
{
|
||||
RewardRarity rarity = RewardRarity.COMMON;
|
||||
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1, rarity));
|
||||
if (_carlSpinner)
|
||||
{
|
||||
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
|
||||
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 25, rarity));
|
||||
}
|
||||
else
|
||||
{
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 5, rarity));
|
||||
}
|
||||
|
||||
//Increase Value
|
||||
if (_doubleGadgetValue)
|
||||
@ -102,14 +116,25 @@ public class RewardManager
|
||||
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.TNT), rarity, 10));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
|
||||
{
|
||||
RewardRarity rarity = RewardRarity.UNCOMMON;
|
||||
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
|
||||
if (_carlSpinner)
|
||||
{
|
||||
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity));
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity));
|
||||
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 1200, rarity));
|
||||
}
|
||||
else
|
||||
{
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
|
||||
}
|
||||
|
||||
//Increase Value
|
||||
if (_doubleGadgetValue)
|
||||
@ -190,12 +215,22 @@ public class RewardManager
|
||||
new ItemStack(2267), rarity, 25));
|
||||
}
|
||||
|
||||
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
|
||||
{
|
||||
RewardRarity rarity = RewardRarity.RARE;
|
||||
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
|
||||
if (_carlSpinner)
|
||||
{
|
||||
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 150, rarity));
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 150, rarity));
|
||||
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 150, rarity));
|
||||
}
|
||||
else
|
||||
{
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
|
||||
}
|
||||
|
||||
|
||||
// Mounts
|
||||
addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule",
|
||||
@ -239,15 +274,23 @@ public class RewardManager
|
||||
new ItemStack(Material.GOLD_LEGGINGS), rarity, 50));
|
||||
addReward(new UnknownPackageReward(donationManager, "Space Boots", "Space Boots",
|
||||
new ItemStack(Material.GOLD_BOOTS), rarity, 50));
|
||||
|
||||
}
|
||||
|
||||
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
|
||||
{
|
||||
RewardRarity rarity = RewardRarity.LEGENDARY;
|
||||
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
|
||||
if (_carlSpinner)
|
||||
{
|
||||
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 10, rarity));
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 10, rarity));
|
||||
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 10, rarity));
|
||||
}
|
||||
else
|
||||
{
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
|
||||
}
|
||||
|
||||
// Mounts
|
||||
addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror",
|
||||
@ -276,6 +319,8 @@ public class RewardManager
|
||||
new ItemStack(Material.APPLE), rarity, 4));
|
||||
addReward(new UnknownPackageReward(donationManager, "Heart Particles", "I Heart You",
|
||||
new ItemStack(Material.BLAZE_POWDER), rarity, 2));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addReward(Reward reward)
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.core.reward;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import static mineplex.core.common.util.C.*;
|
||||
|
||||
@ -14,20 +18,31 @@ public enum RewardRarity
|
||||
* (Fireworks, sounds, etc)
|
||||
*/
|
||||
|
||||
OTHER("Other", cWhite),
|
||||
COMMON("Common", cWhite),
|
||||
UNCOMMON("Uncommon", cAqua),
|
||||
RARE("Rare", cPurple),
|
||||
LEGENDARY("Legendary", cGreen),
|
||||
MYTHICAL("Mythical", cRed);
|
||||
OTHER("Other", cWhite, Material.STAINED_GLASS_PANE, (byte) 0),
|
||||
COMMON("Common", cWhite, Material.STAINED_GLASS_PANE, (byte) 0),
|
||||
GAME("Game", cYellow, Material.STAINED_GLASS_PANE, (byte) 4),
|
||||
UNCOMMON("Uncommon", cAqua, Material.STAINED_GLASS_PANE, (byte) 3),
|
||||
RARE("Rare", cPurple, Material.STAINED_GLASS_PANE, (byte) 10),
|
||||
LEGENDARY("Legendary", cGreen, Material.STAINED_GLASS_PANE, (byte) 5),
|
||||
MYTHICAL("Mythical", cRed, Material.STAINED_GLASS_PANE, (byte) 14);
|
||||
|
||||
private String _name;
|
||||
private String _color;
|
||||
private Material _material;
|
||||
private byte _data;
|
||||
private ItemStack _stack;
|
||||
|
||||
RewardRarity(String name, String color)
|
||||
RewardRarity(String name, String color, Material material, byte data)
|
||||
{
|
||||
_name = name;
|
||||
_color = color;
|
||||
_material = material;
|
||||
_data = data;
|
||||
|
||||
_stack = new ItemStack(getMaterial(), 1, (short) 0, getData());
|
||||
ItemMeta meta = _stack.getItemMeta();
|
||||
meta.setDisplayName(_color + _name);
|
||||
_stack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
public String getColor()
|
||||
@ -40,4 +55,19 @@ public enum RewardRarity
|
||||
return _name;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return _material;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return _stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,13 @@ public enum RewardType
|
||||
{
|
||||
//% Chances Mythic Legend Rare Uncommon
|
||||
GameLoot( 0.000001, 0.00001, 0.0001, 3),
|
||||
|
||||
OldChest( 0, 0.05, 0.4, 5),
|
||||
AncientChest( 0, 1, 4, 25),
|
||||
MythicalChest( 0.4, 3, 12, 75);
|
||||
MythicalChest( 0.4, 3, 12, 75),
|
||||
|
||||
SpinnerFiller( 0.1, 1, 4, 20),
|
||||
SpinnerReal( 0.000001, 0.05, 0.4, 5);
|
||||
|
||||
private double _mythicalChance;
|
||||
private double _legendaryChance;
|
||||
|
@ -37,7 +37,7 @@ public class CoinReward extends Reward
|
||||
@Override
|
||||
public RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int gemsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount;
|
||||
int coinsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount;
|
||||
|
||||
_donationManager.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@ -46,9 +46,15 @@ public class CoinReward extends Reward
|
||||
{
|
||||
|
||||
}
|
||||
}, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), gemsToReward);
|
||||
}, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), coinsToReward);
|
||||
|
||||
return new RewardData(getRarity().getColor() + gemsToReward + " Coins", new ItemStack(175));
|
||||
return new RewardData(getRarity().getColor() + coinsToReward + " Coins", new ItemStack(175), getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getColor() + "Coins", new ItemStack(175), getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,52 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class ExperienceReward extends Reward
|
||||
{
|
||||
private StatsManager _statsManager;
|
||||
private Random _random;
|
||||
private int _minExperience;
|
||||
private int _maxExperience;
|
||||
|
||||
public ExperienceReward(StatsManager statsManager, int minExperience, int maxExperience, int weight, RewardRarity rarity)
|
||||
{
|
||||
super(rarity, weight);
|
||||
|
||||
_statsManager = statsManager;
|
||||
_random = new Random();
|
||||
_minExperience = minExperience;
|
||||
_maxExperience = maxExperience;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int experience = _random.nextInt(_maxExperience - _minExperience) + _minExperience;
|
||||
|
||||
_statsManager.incrementStat(player, "Global.ExpEarned", experience);
|
||||
|
||||
return new RewardData(getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), RewardRarity.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), RewardRarity.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
public class GemReward extends Reward
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private Random _random;
|
||||
private int _minGemCount;
|
||||
private int _maxGemCount;
|
||||
|
||||
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity)
|
||||
{
|
||||
this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM);
|
||||
}
|
||||
|
||||
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity, Random random)
|
||||
{
|
||||
super(rarity, weight);
|
||||
_donationManager = donationManager;
|
||||
_minGemCount = minGemCount;
|
||||
_maxGemCount = maxGemCount;
|
||||
|
||||
_random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int GemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount;
|
||||
|
||||
_donationManager.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
|
||||
}
|
||||
}, "Treasure Chest", player.getName(), player.getUniqueId(), GemsToReward);
|
||||
|
||||
return new RewardData(getRarity().getColor() + GemsToReward + " Gems", new ItemStack(Material.EMERALD), getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getColor() + "Gems", new ItemStack(Material.EMERALD), getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof GemReward)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -59,7 +59,13 @@ public class InventoryReward extends Reward
|
||||
|
||||
_inventoryManager.addItemToInventory(player, "Item", _packageName, amountToGive);
|
||||
|
||||
return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack);
|
||||
return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack, getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,12 +33,26 @@ public class RankReward extends Reward
|
||||
else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND;
|
||||
|
||||
if (rank == null)
|
||||
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER));
|
||||
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity());
|
||||
|
||||
_clientManager.Get(player).SetRank(rank);
|
||||
_clientManager.getRepository().saveRank(null, player.getName(), player.getUniqueId(), rank, true);
|
||||
|
||||
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR));
|
||||
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
Rank rank = null;
|
||||
if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA;
|
||||
else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO;
|
||||
else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND;
|
||||
|
||||
if (rank == null)
|
||||
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity());
|
||||
|
||||
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +33,7 @@ public class UnknownPackageReward extends Reward
|
||||
{
|
||||
_donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, true, 0, true);
|
||||
|
||||
return new RewardData(getRarity().getColor() + _name, _itemStack);
|
||||
return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,6 +48,12 @@ public class UnknownPackageReward extends Reward
|
||||
return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity());
|
||||
}
|
||||
|
||||
protected String getPackageName()
|
||||
{
|
||||
return _packageName;
|
||||
|
@ -20,6 +20,7 @@ import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/27/2014.
|
||||
@ -32,19 +33,19 @@ public class TreasureManager extends MiniPlugin
|
||||
private HologramManager _hologramManager;
|
||||
private List<TreasureLocation> _treasureLocations;
|
||||
|
||||
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager)
|
||||
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager)
|
||||
{
|
||||
super("Treasure", plugin);
|
||||
|
||||
_inventoryManager = inventoryManager;
|
||||
_blockRestore = blockRestore;
|
||||
_hologramManager = hologramManager;
|
||||
_rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager,
|
||||
_rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager, statsManager,
|
||||
100, 250,
|
||||
500, 1000,
|
||||
4000, 6000,
|
||||
12000, 32000,
|
||||
true);
|
||||
true, false);
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
|
@ -17,6 +17,8 @@ public abstract class Animation
|
||||
_running = true;
|
||||
}
|
||||
|
||||
public Animation() {}
|
||||
|
||||
public void run()
|
||||
{
|
||||
tick();
|
||||
@ -51,4 +53,14 @@ public abstract class Animation
|
||||
return _treasure;
|
||||
}
|
||||
|
||||
public void setRunning(boolean b)
|
||||
{
|
||||
_running = b;
|
||||
}
|
||||
|
||||
public void setTicks(int ticks)
|
||||
{
|
||||
_ticks = ticks;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.votifier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class VotifierCommand extends ServerCommand
|
||||
{
|
||||
private String _playerName;
|
||||
|
||||
public VotifierCommand(String playerName, String... targetServer)
|
||||
{
|
||||
super(targetServer);
|
||||
|
||||
_playerName = playerName;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,7 @@ package mineplex.database.tables;
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class Bonus extends org.jooq.impl.TableImpl<mineplex.database.tables.records.BonusRecord> implements java.io.Serializable, java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -524321170;
|
||||
private static final long serialVersionUID = -384307684;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>Account.bonus</code>
|
||||
@ -54,27 +54,27 @@ public class Bonus extends org.jooq.impl.TableImpl<mineplex.database.tables.reco
|
||||
/**
|
||||
* The column <code>Account.bonus.dailyStreak</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> dailyStreak = createField("dailyStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> dailyStreak = createField("dailyStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.bonus.maxDailyStreak</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> maxDailyStreak = createField("maxDailyStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> maxDailyStreak = createField("maxDailyStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.bonus.voteStreak</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> voteStreak = createField("voteStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> voteStreak = createField("voteStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.bonus.maxVoteStreak</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> maxVoteStreak = createField("maxVoteStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> maxVoteStreak = createField("maxVoteStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.bonus.tickets</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> tickets = createField("tickets", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.lang.Integer> tickets = createField("tickets", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, "");
|
||||
|
||||
/**
|
||||
* Create a <code>Account.bonus</code> table reference
|
||||
|
@ -31,6 +31,7 @@ import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.personalServer.PersonalServerManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
@ -39,7 +40,6 @@ import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.resourcepack.ResUnloadCheck;
|
||||
import mineplex.core.resourcepack.ResPackManager;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -49,7 +49,6 @@ import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
@ -122,7 +121,8 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
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), packetHandler);
|
||||
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, packetHandler);
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
|
||||
|
||||
@ -141,7 +141,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
}
|
||||
});
|
||||
//new Replay(this, packetHandler);
|
||||
new PersonalServerManager(this, clientManager);
|
||||
|
||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||
|
||||
@ -159,7 +158,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, webServerAddress);
|
||||
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, disguiseManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress);
|
||||
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress);
|
||||
classManager.setEnabled(false);
|
||||
|
||||
ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory, achievementManager, clientManager);
|
||||
|
||||
|
@ -3,6 +3,43 @@ package mineplex.hub;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -30,23 +67,26 @@ import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.notifier.NotificationManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.personalServer.PersonalServerManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.hub.commands.DisguiseCommand;
|
||||
import mineplex.hub.commands.ForcefieldRadius;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
@ -61,7 +101,8 @@ import mineplex.hub.modules.ParkourManager;
|
||||
import mineplex.hub.modules.SoccerManager;
|
||||
import mineplex.hub.modules.TextManager;
|
||||
import mineplex.hub.modules.WorldManager;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.hub.profile.gui.GUIProfile;
|
||||
import mineplex.hub.tutorial.TutorialManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
||||
@ -70,42 +111,6 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
// ☃❅ Snowman!
|
||||
@ -118,6 +123,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private DisguiseManager _disguiseManager;
|
||||
private PartyManager _partyManager;
|
||||
private ForcefieldManager _forcefieldManager;
|
||||
private PollManager _pollManager;
|
||||
private Portal _portal;
|
||||
private StatsManager _statsManager;
|
||||
private GadgetManager _gadgetManager;
|
||||
@ -133,6 +139,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private TreasureManager _treasureManager;
|
||||
private PetManager _petManager;
|
||||
private PacketHandler _packetHandler;
|
||||
private PersonalServerManager _personalServerManager;
|
||||
|
||||
private Location _spawn;
|
||||
private int _scoreboardTick = 0;
|
||||
@ -150,7 +157,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
//Admin
|
||||
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, PacketHandler packetHandler)
|
||||
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, PacketHandler packetHandler)
|
||||
{
|
||||
super("Hub Manager", plugin);
|
||||
|
||||
@ -159,6 +166,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_conditionManager = conditionManager;
|
||||
_donationManager = donationManager;
|
||||
_disguiseManager = disguiseManager;
|
||||
_pollManager = pollManager;
|
||||
_personalServerManager = personalServerManager;
|
||||
|
||||
_portal = portal;
|
||||
|
||||
@ -180,7 +189,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_inventoryManager = new InventoryManager(plugin, clientManager);
|
||||
new BenefitManager(plugin, clientManager, _inventoryManager);
|
||||
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager);
|
||||
_treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager);
|
||||
|
||||
_treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager);
|
||||
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
|
||||
|
||||
new SoccerManager(this, _gadgetManager);
|
||||
@ -204,6 +214,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
||||
|
||||
|
||||
new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager);
|
||||
|
||||
|
||||
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
|
||||
// new MailManager(_plugin, notificationManager);
|
||||
|
||||
@ -965,4 +979,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
return _packetHandler;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void openProfile(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM)
|
||||
return;
|
||||
|
||||
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();;
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,20 @@ package mineplex.hub.modules;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
@ -350,6 +354,12 @@ public class SoccerManager extends MiniPlugin
|
||||
if (_ball != null && _ball.equals(ent))
|
||||
continue;
|
||||
|
||||
if (ent instanceof Bat)
|
||||
{
|
||||
ent.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inPlayerArena(ent))
|
||||
{
|
||||
Location bounce = UtilAlg.getMidpoint(_cornerFieldPlayerA, _cornerFieldPlayerB);
|
||||
@ -491,4 +501,30 @@ public class SoccerManager extends MiniPlugin
|
||||
{
|
||||
_active.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void allowDamage(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
|
||||
return;
|
||||
|
||||
Player damager = (Player)event.getDamager();
|
||||
Player damagee = (Player)event.getEntity();
|
||||
|
||||
if (!_active.contains(damager) || !_active.contains(damagee))
|
||||
return;
|
||||
|
||||
if (getTeamColor(damager) == null || getTeamColor(damagee) == null)
|
||||
return;
|
||||
|
||||
if (getTeamColor(damager) == getTeamColor(damagee))
|
||||
return;
|
||||
|
||||
if (Recharge.Instance.use(damagee, "Football Damage", 800, false, false))
|
||||
{
|
||||
UtilAction.velocity(damagee, UtilAlg.getTrajectory2d(damager, damagee), 0.6, false, 0, 0.3, 1, true);
|
||||
|
||||
damagee.playEffect(EntityEffect.HURT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
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,
|
||||
ChatColor.RESET + C.cYellow + "Mineplex Player Server",
|
||||
new String[]
|
||||
{
|
||||
"",
|
||||
C.cWhite + "Create a server where you are the Host.",
|
||||
C.cWhite + "You can choose the game, map and much more!",
|
||||
"",
|
||||
C.cWhite + "Type " + C.cGreen + "/mps" + C.cWhite + " to access this anywhere!"
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
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.RESET + C.cYellow + "Preferences",
|
||||
new String[]
|
||||
{
|
||||
"",
|
||||
C.cWhite + "Set your preferences to your liking",
|
||||
C.cWhite + "so you can enjoy the game more!",
|
||||
|
||||
"",
|
||||
C.cWhite + "Type " + C.cGreen + "/prefs" + C.cWhite + " to access this anywhere!"
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
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.cYellow + "Stats and Achievements",
|
||||
new String[]
|
||||
{
|
||||
"",
|
||||
C.cWhite + "View your Statistics and Achievements",
|
||||
C.cWhite + "for all of the games on Mineplex!",
|
||||
|
||||
"",
|
||||
C.cWhite + "Type " + C.cGreen + "/stats" + C.cWhite + " to access this anywhere!"
|
||||
});
|
||||
SkullMeta meta = ((SkullMeta) item.getItemMeta());
|
||||
meta.setOwner(_player.getName());
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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 ButtonPrefs(this, player));
|
||||
setItem(15, new ButtonMPS(this, player));
|
||||
}
|
||||
|
||||
public PreferencesManager getPrefManager()
|
||||
{
|
||||
return _preferencesManager;
|
||||
}
|
||||
|
||||
public AchievementManager getAchievementManager()
|
||||
{
|
||||
return _achievementManager;
|
||||
}
|
||||
|
||||
public PersonalServerManager getPersonalManager()
|
||||
{
|
||||
return _personalServerManager;
|
||||
}
|
||||
|
||||
}
|
@ -17,8 +17,8 @@ public class PartyTutorial extends Tutorial
|
||||
double y = -manager.GetSpawn().getY();
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 10),
|
||||
manager.GetSpawn().add(81, y+68.5, 10),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Parties",
|
||||
new String[]
|
||||
{
|
||||
@ -32,8 +32,8 @@ public class PartyTutorial extends Tutorial
|
||||
));
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 9),
|
||||
manager.GetSpawn().add(81, y+68.5, 9),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Creating a Party",
|
||||
new String[]
|
||||
{
|
||||
@ -47,8 +47,8 @@ public class PartyTutorial extends Tutorial
|
||||
));
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 9),
|
||||
manager.GetSpawn().add(81, y+68.5, 9),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Inviting and Suggesting Players",
|
||||
new String[]
|
||||
{
|
||||
@ -61,8 +61,8 @@ public class PartyTutorial extends Tutorial
|
||||
));
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 9),
|
||||
manager.GetSpawn().add(81, y+68.5, 9),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Leaving Parties",
|
||||
new String[]
|
||||
{
|
||||
@ -73,8 +73,8 @@ public class PartyTutorial extends Tutorial
|
||||
));
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 9),
|
||||
manager.GetSpawn().add(81, y+68.5, 9),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Kicking Players from Party",
|
||||
new String[]
|
||||
{
|
||||
@ -87,8 +87,8 @@ public class PartyTutorial extends Tutorial
|
||||
));
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 9),
|
||||
manager.GetSpawn().add(81, y+68.5, 9),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Joining Games Together",
|
||||
new String[]
|
||||
{
|
||||
@ -103,8 +103,8 @@ public class PartyTutorial extends Tutorial
|
||||
));
|
||||
|
||||
_phases.add(new TutorialPhase(
|
||||
manager.GetSpawn().add(84, y+69, 9),
|
||||
manager.GetSpawn().add(81, y+68.5, 9),
|
||||
manager.GetSpawn().add(0, 65 + y, 0),
|
||||
manager.GetSpawn().add(4, 66.5 + y, 0),
|
||||
"Party Chat",
|
||||
new String[]
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
||||
public class ServerManager
|
||||
{
|
||||
public static final String SERVER_STATUS_LABEL = "ServerStatus"; // Label differentiating ServerStatus related servers
|
||||
private static final String DEFAULT_CONFIG = "redis-config.dat";
|
||||
|
||||
// Configuration determining connection information
|
||||
private static RedisConfig _config;
|
||||
@ -74,7 +75,7 @@ public class ServerManager
|
||||
|
||||
public static ConnectionData getConnection(boolean writeable, String name)
|
||||
{
|
||||
return getConfig().getConnection(writeable, name);
|
||||
return getConfig(DEFAULT_CONFIG).getConnection(writeable, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,13 +90,13 @@ public class ServerManager
|
||||
/**
|
||||
* @return the {@link RedisConfig} associated with this manager, providing appropriate connections.
|
||||
*/
|
||||
public static RedisConfig getConfig()
|
||||
public static RedisConfig getConfig(String fileName)
|
||||
{
|
||||
if (_config == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
File configFile = new File("redis-config.dat");
|
||||
File configFile = new File(fileName);
|
||||
|
||||
if (configFile.exists())
|
||||
{
|
||||
@ -113,7 +114,7 @@ public class ServerManager
|
||||
}
|
||||
else
|
||||
{
|
||||
log("redis-config.dat not found at " + configFile.toPath().toString());
|
||||
log(fileName + " not found at " + configFile.toPath().toString());
|
||||
_config = new RedisConfig();
|
||||
}
|
||||
}
|
||||
|
27
Plugins/Mineplex.Votifier/Mineplex.Votifier.iml
Normal file
27
Plugins/Mineplex.Votifier/Mineplex.Votifier.iml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../Libraries/Votifier.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
<orderEntry type="module" module-name="Mineplex.Core" />
|
||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||
<orderEntry type="library" name="jedis" level="project" />
|
||||
<orderEntry type="library" name="jooq" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.Core.Common" />
|
||||
<orderEntry type="module" module-name="Mineplex.Database" />
|
||||
</component>
|
||||
</module>
|
3
Plugins/Mineplex.Votifier/plugin.yml
Normal file
3
Plugins/Mineplex.Votifier/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
||||
name: MineplexVotifier
|
||||
main: mineplex.votifier.Votifier
|
||||
version: 0.1
|
@ -0,0 +1,34 @@
|
||||
package mineplex.votifier;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
|
||||
/**
|
||||
* Created by shaun on 15-08-05.
|
||||
*/
|
||||
public class Votifier extends JavaPlugin
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
||||
|
||||
CommandCenter.Initialize(this);
|
||||
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
|
||||
DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress);
|
||||
BonusManager bonusManager = new BonusManager(this, clientManager, donationManager);
|
||||
|
||||
|
||||
VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,231 @@
|
||||
package mineplex.votifier;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.votifier.VotifierCommand;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.data.PlayerStatus;
|
||||
import mineplex.serverdata.redis.RedisConfig;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
|
||||
/**
|
||||
* Created by shaun on 15-08-05.
|
||||
*/
|
||||
public class VotifierManager extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
private RedisConfig _usConfig;
|
||||
private RedisConfig _euConfig;
|
||||
private RedisDataRepository<PlayerStatus> _usPlayerRepo;
|
||||
private RedisDataRepository<PlayerStatus> _euPlayerRepo;
|
||||
private JedisPool _usWritePool;
|
||||
private JedisPool _euWritePool;
|
||||
|
||||
public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager)
|
||||
{
|
||||
super("Votifier", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_bonusManager = bonusManager;
|
||||
|
||||
_usConfig = ServerManager.getConfig("us-redis.dat");
|
||||
_euConfig = ServerManager.getConfig("eu-redis.dat");
|
||||
|
||||
_usPlayerRepo = new RedisDataRepository<PlayerStatus>(_usConfig.getConnection(true, "DefaultConnection"),
|
||||
_usConfig.getConnection(false, "DefaultConnection"), Region.US, PlayerStatus.class, "playerStatus");
|
||||
_euPlayerRepo = new RedisDataRepository<PlayerStatus>(_euConfig.getConnection(true, "DefaultConnection"),
|
||||
_euConfig.getConnection(false, "DefaultConnection"), Region.EU, PlayerStatus.class, "playerStatus");
|
||||
|
||||
_usWritePool = Utility.generatePool(_usConfig.getConnection(true, "DefaultConnection"));
|
||||
_euWritePool = Utility.generatePool(_euConfig.getConnection(true, "DefaultConnection"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleVote(VotifierEvent event)
|
||||
{
|
||||
Vote vote = event.getVote();
|
||||
String playerName = vote.getUsername();
|
||||
|
||||
System.out.println("New Vote: " + playerName);
|
||||
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
if (uuid == null)
|
||||
{
|
||||
System.out.println("Failed to load UUID of " + playerName + " from UUIDFetcher. Trying with database");
|
||||
uuid = _clientManager.loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid == null)
|
||||
{
|
||||
System.out.println("Failed to load UUID from database. Giving up on " + playerName);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Loaded " + playerName + " with uuid " + uuid);
|
||||
System.out.println("Attempting to award bonus");
|
||||
awardBonus(playerName, uuid);
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
|
||||
// UUID uuid = _clientManager.loadUUIDFromDB(playerName);
|
||||
// if (uuid != null)
|
||||
// {
|
||||
// System.out.println("Found UUID:" + uuid.toString());
|
||||
// if (playerName.equalsIgnoreCase("Phinary"))
|
||||
// {
|
||||
// System.out.println("award bonus");
|
||||
// awardBonus(uuid);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// System.out.println("Failed to load UUID for player: " + playerName);
|
||||
// }
|
||||
|
||||
// PlayerStatus usStatus = _usPlayerRepo.getElement(playerName);
|
||||
// if (usStatus != null)
|
||||
// {
|
||||
// System.out.println("Found on US Server: " + usStatus.getServer());
|
||||
// writePool = _usWritePool;
|
||||
// serverName = usStatus.getServer();
|
||||
// }
|
||||
//
|
||||
// PlayerStatus euStatus = _euPlayerRepo.getElement(playerName);
|
||||
// if (euStatus != null)
|
||||
// {
|
||||
// System.out.println("Found on EU Server: " + euStatus.getServer());
|
||||
// writePool = _euWritePool;
|
||||
// serverName = euStatus.getServer();
|
||||
// }
|
||||
|
||||
// Currently we just notify all servers, and the server with the player on it can deal with it
|
||||
notifyServer(playerName, false);
|
||||
// notifyServer(playerName, true);
|
||||
}
|
||||
|
||||
private void notifyServer(String playerName, boolean eu)
|
||||
{
|
||||
JedisPool writePool = eu ? _euWritePool : _usWritePool;
|
||||
|
||||
VotifierCommand command = new VotifierCommand(playerName);
|
||||
publishCommand(command, writePool);
|
||||
}
|
||||
|
||||
private void awardBonus(final String playerName, UUID uuid)
|
||||
{
|
||||
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||
|
||||
Record1<Integer> idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne();
|
||||
if (idRecord != null)
|
||||
{
|
||||
final int accountId = idRecord.value1();
|
||||
final BonusClientData client = new BonusClientData(_bonusManager.getRepository().loadRecord(playerName, accountId));
|
||||
|
||||
final BonusAmount amount = _bonusManager.getVoteBonusAmount(client);
|
||||
|
||||
// Reward Amount
|
||||
if (amount.getTickets() > 0)
|
||||
client.setTickets(client.getTickets() + amount.getTickets());
|
||||
|
||||
if (amount.getGems() > 0)
|
||||
{
|
||||
_donationManager.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " gems to " + playerName);
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName);
|
||||
}
|
||||
}, "Votifier", playerName, uuid, amount.getGems());
|
||||
}
|
||||
|
||||
if (amount.getCoins() > 0)
|
||||
{
|
||||
_donationManager.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " coins to " + playerName);
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getGems() + " coins to " + playerName);
|
||||
}
|
||||
}, "Votifier", playerName, accountId, amount.getCoins());
|
||||
}
|
||||
|
||||
// Update time
|
||||
client.getRecord().setVotetime(new Date(_bonusManager.getSqlTime()));
|
||||
|
||||
// Update Streak
|
||||
_bonusManager.incrementVoteStreak(client);
|
||||
|
||||
client.getRecord().store();
|
||||
System.out.println("Awarded carl ticket to " + playerName);
|
||||
}
|
||||
}
|
||||
|
||||
private void publishCommand(final ServerCommand serverCommand, final JedisPool writePool)
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Jedis jedis = writePool.getResource();
|
||||
|
||||
try
|
||||
{
|
||||
String commandType = serverCommand.getClass().getSimpleName();
|
||||
String serializedCommand = Utility.serialize(serverCommand);
|
||||
jedis.publish("commands.server" + ":" + commandType, serializedCommand);
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
writePool.returnBrokenResource(jedis);
|
||||
jedis = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (writePool != null)
|
||||
{
|
||||
writePool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
@ -89,10 +89,10 @@ public class MenuPage extends BasePage
|
||||
if (host)
|
||||
{
|
||||
GiveAdminButton giveAdminButton = new GiveAdminButton(getPlugin(), getShop());
|
||||
addButton(4 + 9, new ShopItem(Material.DIAMOND_SWORD, "Give Admin", new String[]{}, 1, false), giveAdminButton);
|
||||
addButton(4 + 9, new ShopItem(Material.DIAMOND_SWORD, "Give Co-Host", new String[]{}, 1, false), giveAdminButton);
|
||||
|
||||
RemoveAdminButton removeAdminButton = new RemoveAdminButton(getPlugin(), getShop());
|
||||
addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Admin", new String[]{}, 1, false), removeAdminButton);
|
||||
addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Co-Host", new String[]{}, 1, false), removeAdminButton);
|
||||
|
||||
KillButton killButton = new KillButton(getPlugin());
|
||||
addButton(8 + 18, new ShopItem(Material.TNT, "Kill Private Server",
|
||||
|
@ -90,9 +90,9 @@ public class GameChatManager implements Listener
|
||||
else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false))
|
||||
{
|
||||
if (Manager.GetGameHostManager().isEventServer())
|
||||
rankStr = C.cDGreen + C.Bold + "Event Admin ";
|
||||
rankStr = C.cDGreen + C.Bold + "Event Co-Host ";
|
||||
else
|
||||
rankStr = C.cDGreen + C.Bold + "MPS Admin ";
|
||||
rankStr = C.cDGreen + C.Bold + "MPS Co-Host ";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ public class GameGemManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
|
||||
boolean DoubleGem = true;
|
||||
boolean DoubleGem = false;
|
||||
|
||||
public GameGemManager(ArcadeManager manager)
|
||||
{
|
||||
|
@ -230,6 +230,10 @@ public class GameHostManager implements Listener
|
||||
_hostRank = Manager.GetClients().Get(_host).GetRank();
|
||||
System.out.println("Game Host Joined.");
|
||||
|
||||
//Limit player count!
|
||||
if (Manager.GetServerConfig().MaxPlayers > getMaxPlayerCap())
|
||||
Manager.GetServerConfig().MaxPlayers = getMaxPlayerCap();
|
||||
|
||||
if (isEventServer())
|
||||
worldeditPermissionSet(event.getPlayer(), true);
|
||||
}
|
||||
@ -642,7 +646,7 @@ public class GameHostManager implements Listener
|
||||
{
|
||||
_adminList.add(player.getName());
|
||||
_onlineAdmins.add(player);
|
||||
UtilPlayer.message(player, F.main("Server", "You were given admin privileges."));
|
||||
UtilPlayer.message(player, F.main("Server", "You were given Co-Host privileges."));
|
||||
|
||||
if (isEventServer())
|
||||
worldeditPermissionSet(player, true);
|
||||
@ -660,7 +664,7 @@ public class GameHostManager implements Listener
|
||||
{
|
||||
player.closeInventory();
|
||||
}
|
||||
UtilPlayer.message(player, F.main("Server", "Your admin privileges were removed."));
|
||||
UtilPlayer.message(player, F.main("Server", "Your Co-Host privileges were removed."));
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
|
@ -50,12 +50,12 @@ public class GameLootManager implements Listener
|
||||
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
|
||||
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager,
|
||||
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(),
|
||||
100, 250,
|
||||
500, 1000,
|
||||
1500, 2500,
|
||||
6000, 12000,
|
||||
false);
|
||||
false, false);
|
||||
|
||||
//Chest
|
||||
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Old Chest", "Old Chest", 1, 1,
|
||||
|
Loading…
Reference in New Issue
Block a user