Merge branch 'develop' into update/stpatrickscosmetics

This commit is contained in:
LCastr0 2017-03-12 20:54:48 -03:00
commit c54cd066ef
83 changed files with 2861 additions and 720 deletions

View File

@ -3,6 +3,8 @@ package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -477,5 +479,35 @@ public class UtilInv
{
shooter.getInventory().addItem(new ItemStack(material, amount, data));
}
/**
* Checks if an InventoryClickEvent should be cancelled based on the given predicate. The predicate should return true
* if the given ItemStack is one that should not be moved
*/
public static boolean shouldCancelEvent(InventoryClickEvent event, Predicate<ItemStack> predicate)
{
List<ItemStack> check = new ArrayList<>();
if (event.getHotbarButton() != -1)
{
check.add(event.getWhoClicked().getInventory().getItem(event.getHotbarButton())); // Check item in hotbar slot
ItemStack other = event.getCurrentItem();
if (other != null && other.getType() != Material.AIR)
check.add(other); // Check the other slot (where the cursor is)
}
else
{
ItemStack other = event.getCurrentItem();
if (other != null && other.getType() != Material.AIR)
check.add(other); // Check the clicked item
}
for (ItemStack item : check)
{
if (predicate.test(item))
return true;
}
return false;
}
}

View File

@ -1302,6 +1302,20 @@ public class UtilItem
return item.getItemMeta().getDisplayName().contains(name);
}
public static String getDisplayName(ItemStack itemStack)
{
if (itemStack == null)
return null;
if (itemStack.getItemMeta() == null)
return null;
if (itemStack.getItemMeta().getDisplayName() == null)
return null;
return itemStack.getItemMeta().getDisplayName();
}
public static boolean isSimilar(ItemStack a, ItemStack b, ItemAttribute... attributes)
{
for (ItemAttribute attr : attributes)

View File

@ -1,6 +1,5 @@
package mineplex.core.antihack;
import javax.xml.bind.DatatypeConverter;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@ -10,20 +9,12 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import javax.xml.bind.DatatypeConverter;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -37,7 +28,6 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonObject;
import com.mineplex.anticheat.MineplexAnticheat;
import com.mineplex.anticheat.api.GameEndEvent;
import com.mineplex.anticheat.api.GameStartEvent;
import com.mineplex.anticheat.api.MineplexLink;
@ -55,13 +45,13 @@ import com.mineplex.anticheat.checks.move.HeadRoll;
import com.mineplex.anticheat.checks.move.Speed;
import com.mineplex.anticheat.checks.player.BadPackets;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.actions.AntiHackAction;
import mineplex.core.antihack.actions.BanwaveAction;
import mineplex.core.antihack.actions.GEPBanAction;
import mineplex.core.antihack.actions.ImmediateBanAction;
import mineplex.core.antihack.actions.NoopAction;
import mineplex.core.antihack.animations.BanwaveAnimationSpin;
@ -72,25 +62,25 @@ import mineplex.core.antihack.commands.AnticheatOnCommand;
import mineplex.core.antihack.commands.DetailedMessagesCommand;
import mineplex.core.antihack.commands.GetVlsCommand;
import mineplex.core.antihack.commands.TestBanCommand;
import mineplex.core.antihack.gep.GwenExtremePrejudice;
import mineplex.core.antihack.guardians.GuardianManager;
import mineplex.core.antihack.logging.AntihackLogger;
import mineplex.core.antihack.redisnotifications.GwenBanNotification;
import mineplex.core.antihack.redisnotifications.GwenBanwaveNotification;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Category;
import mineplex.core.punish.Punish;
import mineplex.core.punish.PunishmentResponse;
import mineplex.serverdata.commands.ServerCommandManager;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ReflectivelyCreateMiniPlugin
public class AntiHack extends MiniPlugin
@ -116,6 +106,9 @@ public class AntiHack extends MiniPlugin
.put(Glide.class, new ImmediateBanAction(10000))
.put(Speed.class, new ImmediateBanAction(10000))
// .put(HeadRoll.class, new ImmediateBanAction(200))
.put(HeadRoll.class, new GEPBanAction(1))
.put(BadPackets.class, new GEPBanAction(300))
.put(KillauraTypeB.class, new GEPBanAction(100))
.build();
private static final AntiHackAction NOOP_ACTION = new NoopAction();
@ -174,6 +167,8 @@ public class AntiHack extends MiniPlugin
player.spigot().sendMessage(minimal);
}
});
new GwenExtremePrejudice(UtilServer.getPlugin());
}
@Override
@ -201,7 +196,7 @@ public class AntiHack extends MiniPlugin
runSync(() -> _banned.remove(uuid));
}
public void doBan(Player player, Class<? extends Check> cause)
public void doBan(Player player, Class<? extends Check> cause, boolean gep)
{
runSync(() ->
{
@ -213,6 +208,10 @@ public class AntiHack extends MiniPlugin
String finalMessage = "[GWEN] " + id;
JsonObject custom = new JsonObject();
custom.addProperty("ban-reason", CheckManager.getCheckSimpleName(cause));
if (gep)
{
custom.addProperty("extreme-prejudice", true);
}
_logger.saveMetadata(player, id, () ->
{
@ -220,7 +219,7 @@ public class AntiHack extends MiniPlugin
{
runAsync(() ->
{
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id).publish();
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
});
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, -1, true, after);

View File

@ -1,18 +1,6 @@
package mineplex.core.antihack.actions;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import com.mineplex.anticheat.checks.combat.KillauraTypeA;
import com.mineplex.anticheat.checks.combat.KillauraTypeD;
import com.mineplex.anticheat.checks.move.Glide;
import com.mineplex.anticheat.checks.move.HeadRoll;
import com.mineplex.anticheat.checks.move.Speed;
import mineplex.core.common.util.UtilServer;
import org.bukkit.event.Listener;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public abstract class AntiHackAction
{

View File

@ -3,6 +3,7 @@ package mineplex.core.antihack.actions;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antihack.banwave.BanWaveManager;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
@ -20,6 +21,11 @@ public class BanwaveAction extends AntiHackAction
@Override
public void handle(PlayerViolationEvent event)
{
if (event.getViolations() >= (Math.floor(getMinVl() * .9)) && event.getPlayer().getMetadata("GWENEXTREMEPREJUDICE").get(0).asBoolean())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), true);
return;
}
if (event.getViolations() >= this.getMinVl())
{
// Delay bans by 6 hours +/- 2 hours for fuzzing

View File

@ -0,0 +1,23 @@
package mineplex.core.antihack.actions;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
public class GEPBanAction extends AntiHackAction
{
public GEPBanAction(int vl)
{
super(vl);
}
@Override
public void handle(PlayerViolationEvent event)
{
if (event.getViolations() >= this.getMinVl() && event.getPlayer().getMetadata("GWENEXTREMEPREJUDICE").get(0).asBoolean())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), true);
}
}
}

View File

@ -1,9 +1,9 @@
package mineplex.core.antihack.actions;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.UtilServer;
public class ImmediateBanAction extends AntiHackAction
{
@ -15,9 +15,14 @@ public class ImmediateBanAction extends AntiHackAction
@Override
public void handle(PlayerViolationEvent event)
{
if (event.getViolations() >= (Math.floor(getMinVl() * .9)) && event.getPlayer().getMetadata("GWENEXTREMEPREJUDICE").get(0).asBoolean())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), true);
return;
}
if (event.getViolations() >= this.getMinVl())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass());
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), false);
}
}
}

View File

@ -0,0 +1,87 @@
package mineplex.core.antihack.gep;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.serverdata.database.DBPool;
public class GwenExtremePrejudice extends MiniPlugin
{
private final List<String> _addresses = new ArrayList<>();
@SuppressWarnings("deprecation")
public GwenExtremePrejudice(JavaPlugin plugin)
{
super("GEP", plugin);
int ticks = 20 * 5 * 60;
int offset = 20 * (int)Math.floor(Math.random() * 10) * 60;
ticks += offset;
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, () ->
{
refreshIPList();
}, 0, ticks);
}
private void refreshIPList()
{
try (Connection c = DBPool.getAccount().getConnection())
{
List<String> addresses = new ArrayList<>();
ResultSet rs = c.prepareStatement("SELECT ipAddress FROM gepAddresses;").executeQuery();
while (rs.next())
{
addresses.add(rs.getString(1));
}
runSync(() ->
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (addresses.contains(player.getAddress().getAddress().getHostAddress()))
{
player.removeMetadata("GWENEXTREMEPREJUDICE", getPlugin());
player.setMetadata("GWENEXTREMEPREJUDICE", new FixedMetadataValue(getPlugin(), true));
}
else
{
player.removeMetadata("GWENEXTREMEPREJUDICE", getPlugin());
player.setMetadata("GWENEXTREMEPREJUDICE", new FixedMetadataValue(getPlugin(), false));
}
}
_addresses.clear();
_addresses.addAll(addresses);
});
}
catch (SQLException e)
{
e.printStackTrace();
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (!_addresses.isEmpty() && _addresses.contains(player.getAddress().getAddress().getHostAddress()))
{
player.removeMetadata("GWENEXTREMEPREJUDICE", getPlugin());
player.setMetadata("GWENEXTREMEPREJUDICE", new FixedMetadataValue(getPlugin(), true));
}
else
{
player.setMetadata("GWENEXTREMEPREJUDICE", new FixedMetadataValue(getPlugin(), false));
}
}
}

View File

@ -10,8 +10,9 @@ public class GwenBanNotification extends ServerCommand
private final String _playerRank;
private final String _hackType;
private final String _metadataId;
private final boolean _extremePrejudice;
public GwenBanNotification(String serverName, String playerName, String playerUUID, String playerRank, String hackType, String metadataId)
public GwenBanNotification(String serverName, String playerName, String playerUUID, String playerRank, String hackType, String metadataId, boolean extremePrejudice)
{
_serverName = serverName;
_playerName = playerName;
@ -19,6 +20,7 @@ public class GwenBanNotification extends ServerCommand
_playerRank = playerRank;
_hackType = hackType;
_metadataId = metadataId;
_extremePrejudice = extremePrejudice;
}
public String getServerName()
@ -35,6 +37,11 @@ public class GwenBanNotification extends ServerCommand
{
return _playerUUID;
}
public String getPlayerRank()
{
return _playerRank;
}
public String getHackType()
{
@ -45,4 +52,9 @@ public class GwenBanNotification extends ServerCommand
{
return _metadataId;
}
}
public boolean isExtremePrejudice()
{
return _extremePrejudice;
}
}

View File

@ -2,18 +2,16 @@ package mineplex.core.bonuses;
import java.util.List;
import org.bukkit.ChatColor;
import mineplex.core.common.util.C;
public class BonusAmount
{
private int _gems;
private int _coins;
private int _gold;
private int _shards;
private GoldAmount _gold = new GoldAmount();
private int _bonusGems;
private int _bonusCoins;
private int _bonusGold;
private int _bonusShards;
private GoldAmount _bonusGold = new GoldAmount();
private int _experience;
private int _bonusExperience;
private int _tickets;
@ -38,24 +36,24 @@ public class BonusAmount
_gems = gems;
}
public int getCoins()
public int getShards()
{
return _coins;
return _shards;
}
public void setCoins(int coins)
public void setShards(int shards)
{
_coins = coins;
_shards = shards;
}
public int getGold()
public GoldAmount getGold()
{
return _gold;
}
public void setGold(int gold)
public void setGold(Integer serverId, Integer gold)
{
_gold = gold;
_gold.setGoldFor(serverId, gold);
}
public int getBonusGems()
@ -68,24 +66,24 @@ public class BonusAmount
_bonusGems = bonusGems;
}
public int getBonusCoins()
public int getBonusShards()
{
return _bonusCoins;
return _bonusShards;
}
public void setBonusCoins(int bonusCoins)
public void setBonusShards(int bonusShards)
{
_bonusCoins = bonusCoins;
_bonusShards = bonusShards;
}
public int getBonusGold()
public GoldAmount getBonusGold()
{
return _bonusGold;
}
public void setBonusGold(int bonusGold)
public void setBonusGold(Integer serverId, Integer bonusGold)
{
_bonusGold = bonusGold;
_bonusGold.setGoldFor(serverId, bonusGold);
}
public int getTotalGems()
@ -93,14 +91,14 @@ public class BonusAmount
return getGems() + getBonusGems();
}
public int getTotalCoins()
public int getTotalShards()
{
return getCoins() + getBonusCoins();
return getShards() + getBonusShards();
}
public int getTotalGold()
{
return getGold() + getBonusGold();
return getGold().getTotalGold() + getBonusGold().getTotalGold();
}
public int getExperience()
@ -190,16 +188,16 @@ public class BonusAmount
public boolean isGreaterThanZero()
{
return _bonusCoins > 0 || _coins > 0 || _bonusGems > 0 || _gems > 0 || _gold > 0 || _bonusGold > 0 || _oldChests > 0 || _ancientChests > 0 || _mythicalChests > 0;
return _bonusShards > 0 || _shards > 0 || _bonusGems > 0 || _gems > 0 || _gold.getTotalGold() > 0 || _bonusGold.getTotalGold() > 0 || _oldChests > 0 || _ancientChests > 0 || _mythicalChests > 0;
}
public void addLore(List<String> lore)
{
lore.add(C.cYellow + "Rewards");
addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : ""));
addLore(lore, getCoins(), getBonusCoins(), "Treasure Shards");
addLore(lore, getShards(), getBonusShards(), "Treasure Shards");
addLore(lore, getGems(), getBonusGems(), "Gems");
addLore(lore, getGold(), getBonusGold(), "Gold");
addLore(lore, getGold().getTotalGold(), getBonusGold().getTotalGold(), "Gold");
addLore(lore, getExperience(), getBonusExperience(), "Experience");
addLore(lore, getOldChests(), 0, "Old Chest", "Old Chests");
addLore(lore, getAncientChests(), 0, "Ancient Chest", "Ancient Chests");
@ -211,7 +209,9 @@ public class BonusAmount
private void addLore(List<String> lore, int amount, int bonus, String suffix)
{
if (amount > 0)
{
lore.add(" " + C.cWhite + amount + " " + suffix);
}
// if (bonus > 0)
// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix);
@ -220,8 +220,12 @@ public class BonusAmount
private void addLore(List<String> lore, int amount, int bonus, String suffix, String plural)
{
if (amount == 1)
{
lore.add(" " + C.cWhite + amount + " " + plural);
}
else if (amount > 0)
{
lore.add(" " + C.cWhite + amount + " " + suffix);
}
}
}

View File

@ -4,7 +4,6 @@ import java.sql.Date;
import java.sql.Timestamp;
import mineplex.core.hologram.Hologram;
import mineplex.database.tables.records.BonusRecord;
public class BonusClientData
{
@ -12,8 +11,10 @@ public class BonusClientData
private int _accountId;
private Timestamp _dailyTime;
private Timestamp _clansDailyTime;
private Date _rankTime;
private Date _voteTime;
private Date _clansVoteTime;
private int _dailyStreak;
private int _maxDailyStreak;
private int _voteStreak;
@ -44,6 +45,16 @@ public class BonusClientData
{
return _dailyTime;
}
public void setClansDailyTime(Timestamp value)
{
_clansDailyTime = value;
}
public Timestamp getClansDailyTime()
{
return _clansDailyTime;
}
public void setRankTime(Date value)
{
@ -64,6 +75,16 @@ public class BonusClientData
{
return _voteTime;
}
public void setClansVoteTime(Date value)
{
_clansVoteTime = value;
}
public Date getClansVoteTime()
{
return _clansVoteTime;
}
public void setDailyStreak(Integer value)
{

View File

@ -7,12 +7,13 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.EntityCreeper;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -44,6 +45,9 @@ import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.bonuses.gui.BonusGui;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Pair;
import mineplex.core.common.Rank;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -76,20 +80,28 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.youtube.YoutubeManager;
import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.database.DBPool;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.EntityCreeper;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
{
public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
private static long timeOffSet = 0;
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
private HashMap<String, Boolean> _showCarl = new HashMap<>();
private final Map<UUID, Pair<String, Integer>> _homeServerMap = new ConcurrentHashMap<>();
private Map<String, Boolean> _showCarl = new HashMap<>();
private long _explode;
private boolean _canVote;
private boolean _animationRunning;
public final boolean ClansBonus;
public static long getSqlTime()
{
@ -135,8 +147,58 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private Location _carlLocation;
private AnimationCarl _animation;
private int _visualTick;
private ArrayList<String> _voteList;
private List<Pair<String, String>> _youtubers;
private String _creeperName;
/**
* THIS SHOULD ONLY BE USED FOR VOTIFIER!
*/
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Bonus", plugin);
_enabled = false;
public BonusManager(JavaPlugin plugin, Location carlLocation, PlayWireManager playWireManager, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager)
_repository = new BonusRepository(plugin, this, donationManager);
_clientManager = clientManager;
_donationManager = donationManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager);
System.out.print("VOTIFIER: ");
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
ClansBonus = _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub");
_voteList = new ArrayList<>();
if (ClansBonus)
{
_voteList.add("http://cvote1.mineplex.com");
_voteList.add("http://cvote2.mineplex.com");
_voteList.add("http://cvote3.mineplex.com");
}
else
{
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
}
_youtubers = new ArrayList<>();
if (!ClansBonus)
{
_youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1"));
_youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1"));
}
_youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1"));
_creeperName = "Carl";
updateOffSet();
}
public BonusManager(JavaPlugin plugin, Location carlLocation, PlayWireManager playWireManager, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager, String creeperName)
{
super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager);
@ -146,13 +208,14 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_hologramManager = hologramManager;
_inventoryManager = inventoryManager;
_thankManager = thankManager;
_creeperName = creeperName;
if (gadgetManager == null)
{
System.out.print("GM NULL");
}
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, gadgetManager);
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, gadgetManager, statsManager);
_pollManager = pollManager;
_statsManager = statsManager;
@ -162,10 +225,35 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_playWireManager = playWireManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager);
ClansBonus = _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub");
_voteList = new ArrayList<>();
if (ClansBonus)
{
_voteList.add("http://cvote1.mineplex.com");
_voteList.add("http://cvote2.mineplex.com");
_voteList.add("http://cvote3.mineplex.com");
}
else
{
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
}
_canVote = true;
_youtubers = new ArrayList<>();
if (!ClansBonus)
{
_youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1"));
_youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1"));
}
_youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1"));
if (npcManager != null)
{
_carlNpc = _npcManager.getNpcByName("Carl the Creeper");
_carlNpc = _npcManager.getNpcByName(_creeperName + " the Creeper");
if (_carlNpc == null)
{
_enabled = false;
@ -187,8 +275,38 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
clientManager.addStoredProcedureLoginProcessor(this);
ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, new VoteHandler(this));
updateOffSet();
if (ClansBonus)
{
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor()
{
@Override
public String getName()
{
return "clans-server-id-loader";
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
{
boolean hasRow = resultSet.next();
if (hasRow)
{
_homeServerMap.put(uuid, Pair.create(resultSet.getString(1), resultSet.getInt(2)));
}
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT cs.serverName, cs.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer AS cs ON clans.serverId = cs.id WHERE accountClan.accountId = " + accountId + ";";
}
});
}
}
@ -210,6 +328,53 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet();
}
public String getCreeperName()
{
return _creeperName;
}
public Pair<String, Integer> getClansHomeServer(Player player)
{
if (ClansBonus)
{
return _homeServerMap.getOrDefault(player.getUniqueId(), Pair.create("No Server", -1));
}
else
{
return Pair.create("No Server", -1);
}
}
public void handleVote(final Player player, final int rewardReceived, final boolean clans)
{
final int accountId = _clientManager.getAccountId(player);
runAsync(() -> _repository.getClientData(accountId, data -> runSync(() ->
{
BonusClientData oldData = Get(player);
if (oldData != null)
{
data.setHologram(oldData.getHologram());
}
Set(player, data);
if (clans)
{
_statsManager.incrementStat(player, "Global.ClansDailyVote", 1);
addPendingExplosion(player, player.getName());
UtilPlayer.message(player, F.main(_creeperName, "Thanks for voting for Mineplex Clans!"));
UtilPlayer.message(player, F.main(_creeperName, "You received " + F.elem(rewardReceived + " Gold") + " on your home server and " + F.elem("1 Spinner Ticket") + "!"));
}
else
{
_statsManager.incrementStat(player, "Global.DailyVote", 1);
addPendingExplosion(player, player.getName());
UtilPlayer.message(player, F.main(_creeperName, "Thanks for voting for Mineplex!"));
UtilPlayer.message(player, F.main(_creeperName, "You received " + F.elem(rewardReceived + " Gems") + " and " + F.elem("1 Spinner Ticket") + "!"));
}
})));
}
@EventHandler
public void fireCreeper(UpdateEvent event)
{
@ -222,12 +387,16 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (_animationRunning)
return;
if (!_canVote)
return;
if (!_enabled)
return;
_animationRunning = true;
_explode = System.currentTimeMillis();
_animation.setTicks(0);
_canVote = false;
}
@EventHandler
@ -236,6 +405,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (event.getType() != UpdateType.TICK)
return;
if (_canVote)
return;
if (!_enabled)
return;
@ -275,6 +447,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
DecreaseSize(creeper);
_pendingExplosions.remove(0);
_pendingExplosionsPlayers.remove(0);
_canVote = true;
}
@EventHandler
@ -312,23 +485,29 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20;
public static final long DAILY_STREAK_RESET_TIME = 1000 * 60 * 60 * 12;
public static final long VOTE_STREAK_RESET_TIME = 1000 * 60 * 60 * 24;
public void attemptDailyBonus(final Player player, final BonusAmount amount, final Callback<Boolean> result)
public void attemptDailyBonus(final Player player, final BonusAmount amount, final boolean clans, final Callback<Boolean> result)
{
if (timeTillDailyBonus(player) > 0)
result.run(false);
getRepository().attemptDailyBonus(player, r ->
getRepository().attemptDailyBonus(player, ClansBonus, r ->
{
if (r)
{
incrementDailyStreak(player);
if (ClansBonus)
{
_statsManager.incrementStat(player, "Global.ClansDailyReward", 1);
}
else
{
incrementDailyStreak(player);
_statsManager.incrementStat(player, "Global.DailyReward", 1);
}
awardBonus(player, amount);
updateCreeperVisual(player, true, C.cAqua);
UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!"));
_statsManager.incrementStat(player, "Global.DailyReward", 1);
UtilPlayer.message(player, F.main(_creeperName, "Come back tomorrow for more!"));
}
result.run(r);
@ -343,7 +522,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
// This calculates the the next daily bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
public long nextDailyBonus(Player player)
{
Timestamp timestamp = Get(player).getDailyTime();
Timestamp timestamp = ClansBonus ? Get(player).getClansDailyTime() : Get(player).getDailyTime();
if (timestamp == null)
return 0;
@ -365,7 +544,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
awardBonus(player, getRankBonusAmount(player));
updateCreeperVisual(player, true, C.cAqua);
UtilPlayer.message(player, F.main("Carl", "Come back next month for more!"));
UtilPlayer.message(player, F.main(_creeperName, "Come back next month for more!"));
}
result.run(aBoolean);
@ -393,7 +572,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
else
{
UtilPlayer.message(player, F.main("Carl", "There was an error processing your request. Try again later"));
UtilPlayer.message(player, F.main(_creeperName, "There was an error processing your request. Try again later"));
}
});
}
@ -405,7 +584,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return nextRankBonus(player) - getLocalTime();
}
// This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
public long nextRankBonus(Player player)
{
@ -416,7 +594,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
long lastBonus = date.getTime();
return getNextRankBonusTime(getLocalTime(lastBonus));
}
@ -434,6 +611,20 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
}
}
public void updateVoteStreak(BonusRecord client)
{
if (client.getVoteStreak() > 0 && client.getVotetime() != null)
{
long lastBonus = getLocalTime(client.getVotetime().getTime());
long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME);
if (timeLeft < 0)
{
client.setVoteStreak(0);
}
}
}
public void incrementDailyStreak(Player player)
{
@ -444,6 +635,16 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (data.getDailyStreak() > data.getMaxDailyStreak())
data.setMaxDailyStreak(data.getDailyStreak());
}
public void incrementVoteStreak(BonusRecord client)
{
client.setVoteStreak(client.getVoteStreak() + 1);
if (client.getVoteStreak() > client.getMaxVoteStreak())
{
client.setMaxVoteStreak(client.getVoteStreak());
}
}
public boolean continueStreak(long localLastBonus, long extendTime)
{
@ -459,7 +660,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
public static long getNextRankBonusTime(long time)
{
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TIMEZONE);
calendar.setTimeInMillis(time);
@ -484,25 +684,84 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (streak >= 40) multiplier += (1 * (streak - 40));
return multiplier;
}
public int getVoteMultiplier(int streak)
{
int multiplier = Math.min(100, 5 * streak);
if (streak >= 20)
{
multiplier += (1 * (streak - 40));
}
return multiplier;
}
public BonusAmount getDailyBonusAmount(Player player)
{
double mult = getDailyMultiplier(player) / 100.0;
BonusAmount amount = new BonusAmount();
int coins = 100;
int shards = 100;
int gems = 100;
int experience = 250;
amount.setCoins(coins);
amount.setShards(shards);
amount.setGems(gems);
amount.setExperience(experience);
amount.setBonusCoins((int) (mult * coins));
amount.setBonusShards((int) (mult * shards));
amount.setBonusGems((int) (mult * gems));
amount.setBonusExperience((int) (mult * experience));
return amount;
}
public BonusAmount getClansDailyBonusAmount(Player player)
{
BonusAmount amount = new BonusAmount();
int serverId = getClansHomeServer(player).getRight();
if (serverId != -1)
{
amount.setGold(serverId, 500);
}
return amount;
}
public BonusAmount getVoteBonusAmount(Player player)
{
return getVoteBonusAmount(Get(player).getVoteStreak());
}
public BonusAmount getVoteBonusAmount(int voteStreak)
{
double mult = getVoteMultiplier(voteStreak) / 100.0;
BonusAmount amount = new BonusAmount();
amount.setTickets(1);
amount.setGems(400);
amount.setBonusGems((int) (mult * 400));
return amount;
}
public BonusAmount getClansVoteBonusAmount(Player player)
{
return getClansVoteBonusAmount(getClansHomeServer(player).getRight());
}
public BonusAmount getClansVoteBonusAmount(int serverId)
{
BonusAmount amount = new BonusAmount();
if (serverId != -1)
{
amount.setTickets(1);
amount.setGold(serverId, 1000);
}
return amount;
}
public BonusAmount getRankBonusAmount(Player player)
{
@ -535,6 +794,26 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return data;
}
//VOTE
public long timeTillVoteBonus(Player player)
{
return nextVoteTime(player) - getLocalTime();
}
// This calculates the the next vote bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
public long nextVoteTime(Player player)
{
Date date = ClansBonus ? Get(player).getClansVoteTime() : Get(player).getVoteTime();
if (date == null)
{
return 0;
}
long lastBonus = date.getTime();
return getNextVoteTime(getLocalTime(lastBonus));
}
public void awardBonus(final Player player, BonusAmount amount)
{
@ -543,7 +822,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
final int gems = amount.getTotalGems();
final int gold = amount.getTotalGold();
final int coins = amount.getTotalCoins();
final int shards = amount.getTotalShards();
final int tickets = amount.getTickets();
int experience = amount.getTotalExperience();
int oldChests = amount.getOldChests();
@ -554,55 +833,62 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (oldChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(oldChests + " Old Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), oldChests));
}
if (ancientChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), ancientChests));
}
if (mythicalChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(mythicalChests + " Mythical Chests")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(mythicalChests + " Mythical Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.MYTHICAL.getItemName()), mythicalChests));
}
if (illuminatedChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(illuminatedChests + " Illuminated Chests")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(illuminatedChests + " Illuminated Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ILLUMINATED.getItemName()), illuminatedChests));
}
if (omegaChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(omegaChests + " Omega Chests")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(omegaChests + " Omega Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OMEGA.getItemName()), omegaChests));
}
if (gems > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(gems + " Gems")));
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", gems);
}
if (gold > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(gold + " Gold")));
Set<Integer> serverIds = new HashSet<>();
serverIds.addAll(amount.getGold().getServerIds());
serverIds.addAll(amount.getBonusGold().getServerIds());
for (Integer serverId : serverIds)
{
_donationManager.getGoldRepository().rewardGold(null, serverId, coreClient.getAccountId(), amount.getGold().getGoldFor(serverId) + amount.getBonusGold().getGoldFor(serverId));
}
}
if (coins > 0)
if (shards > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards")));
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", coins);
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(shards + " Treasure Shards")));
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", shards);
}
if (tickets > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket")));
final int accountId = _clientManager.Get(player).getAccountId();
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(tickets + " Carl Spin Ticket")));
final int accountId = coreClient.getAccountId();
runAsync(() ->
{
try
@ -622,9 +908,30 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (experience > 0)
{
_statsManager.incrementStat(player, "Global.ExpEarned", experience);
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience")));
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(experience + " Experience")));
}
}
public static long getNextVoteTime(long time)
{
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TIMEZONE);
calendar.setTimeInMillis(time);
calendar.add(Calendar.DAY_OF_YEAR, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTimeInMillis();
}
public boolean canVote(Player player)
{
long nextVoteTime = nextVoteTime(player);
return System.currentTimeMillis() >= nextVoteTime;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void openGui(PlayerInteractAtEntityEvent event)
@ -688,8 +995,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
int availableRewards = 0;
if (canVote(player)) availableRewards++;
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
if (_youtubeManager.canYoutube(player)) availableRewards++;
if (_youtubeManager.canSpecificYoutube(player)) availableRewards++;
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
if (canDaily(player)) availableRewards++;
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
@ -849,17 +1158,44 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
{
if (_pollManager.hasPoll(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canSpecificYoutube(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
{
if (_showCarl.containsKey(player.getName()))
{
if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub"))
UtilPlayer.message(player, C.cDGreen + C.Bold + "Carl the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
UtilPlayer.message(player, C.cDGreen + C.Bold + _creeperName + " the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
}
}
}
}
}
public String getVoteLink()
{
long sqlTime = getSqlTime();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(sqlTime);
int date = calendar.get(Calendar.DAY_OF_YEAR);
int index = date % _voteList.size();
return _voteList.get(index);
}
public Pair<String, String> getSpecificCreator()
{
long sqlTime = getSqlTime();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(sqlTime);
int date = calendar.get(Calendar.DAY_OF_YEAR);
if (_youtubers.size() >= 1)
{
int index = date % _youtubers.size();
return _youtubers.get(index);
}
else
{
return Pair.create("MineplexGames", "http://youtube.com/mineplexgamesofficial?sub_confirmation=1");
}
}
/**
* Used for disabling rank rewards during first month of release
@ -923,4 +1259,4 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
_carlLocation = carlLocation;
}
}
}

View File

@ -3,35 +3,35 @@ package mineplex.core.bonuses;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import mineplex.core.common.Pair;
import mineplex.core.common.util.Callback;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.ResultSetCallable;
import mineplex.core.donation.DonationManager;
import mineplex.core.recharge.Recharge;
import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
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;
import mineplex.core.common.Pair;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.recharge.Recharge;
import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.ResultSetCallable;
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 static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, clansdailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, votetime DATE NULL DEFAULT NULL, clansvotetime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));";
private BonusManager _manager;
private DonationManager _donationManager;
@ -63,6 +63,29 @@ public class BonusRepository extends RepositoryBase
System.out.println("Loaded record. Daily time: " + record.getDailytime());
return record;
}
public int loadClansServerId(int accountId)
{
try (Connection connection = getConnection())
{
PreparedStatement s = connection.prepareStatement("SELECT clans.serverId FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId WHERE accountClan.accountId = " + accountId + ";");
ResultSet rs = s.executeQuery();
boolean hasRow = rs.next();
if (hasRow)
{
return rs.getInt(1);
}
else
{
return -1;
}
}
catch (SQLException e)
{
e.printStackTrace();
return -1;
}
}
public BonusClientData loadData(final int accountId, ResultSet resultSet) throws SQLException
{
@ -74,13 +97,15 @@ public class BonusRepository extends RepositoryBase
{
foundClient = true;
clientData.setDailyTime(resultSet.getTimestamp(2));
clientData.setRankTime(resultSet.getDate(3));
clientData.setVoteTime(resultSet.getDate(4));
clientData.setDailyStreak(resultSet.getInt(5));
clientData.setMaxDailyStreak(resultSet.getInt(6));
clientData.setVoteStreak(resultSet.getInt(7));
clientData.setMaxVoteStreak(resultSet.getInt(8));
clientData.setTickets(resultSet.getInt(9));
clientData.setClansDailyTime(resultSet.getTimestamp(3));
clientData.setRankTime(resultSet.getDate(4));
clientData.setVoteTime(resultSet.getDate(5));
clientData.setClansVoteTime(resultSet.getDate(6));
clientData.setDailyStreak(resultSet.getInt(7));
clientData.setMaxDailyStreak(resultSet.getInt(8));
clientData.setVoteStreak(resultSet.getInt(9));
clientData.setMaxVoteStreak(resultSet.getInt(10));
clientData.setTickets(resultSet.getInt(11));
}
if (!foundClient)
@ -170,13 +195,15 @@ public class BonusRepository extends RepositoryBase
});
}
public void attemptDailyBonus(final Player player, final Callback<Boolean> result)
public void attemptDailyBonus(final Player player, final boolean clans, final Callback<Boolean> result)
{
final int accountId = _manager.getClientManager().Get(player).getAccountId();
final int coins = 0;
final int serverId = _manager.getClansHomeServer(player).getRight();
final int shards = 0;
final int gems = 0;
final int gold = 500;
/*
* if (coins == 0 && gems == 0) { result.accept(false); return; }
* if (shards == 0 && gems == 0) { result.accept(false); return; }
*/
final JavaPlugin plug = _manager.getPlugin();
@ -185,46 +212,93 @@ public class BonusRepository extends RepositoryBase
@Override
public void run()
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_daily(?, ?, ?, ?, ?)}"))
if (clans)
{
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);
Bukkit.getScheduler().runTask(plug, new Runnable()
{
@Override
public void run()
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_clans_daily(?, ?, ?, ?, ?)}"))
{
callableStatement.setInt(1, accountId);
callableStatement.setInt(2, serverId);
callableStatement.setInt(3, gold);
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
callableStatement.registerOutParameter(5, java.sql.Types.TIMESTAMP);
if (pass)
callableStatement.executeUpdate();
final boolean pass = callableStatement.getBoolean(4);
final Timestamp timeStamp = callableStatement.getTimestamp(5);
Bukkit.getScheduler().runTask(plug, new Runnable()
{
_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);
}
@Override
public void run()
{
if (pass)
{
_manager.Get(player).setClansDailyTime(new Timestamp(BonusManager.getSqlTime()));
result.run(true);
}
else
{
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false);
_manager.Get(player).setClansDailyTime(timeStamp);
result.run(false);
}
}
});
}
catch (Exception e)
{
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false);
e.printStackTrace();
result.run(false);
}
});
}
catch (Exception e)
else
{
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false);
e.printStackTrace();
result.run(false);
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_daily(?, ?, ?, ?, ?)}"))
{
callableStatement.setInt(1, accountId);
callableStatement.setInt(2, shards);
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);
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);
}
}
}
});
@ -285,7 +359,7 @@ public class BonusRepository extends RepositoryBase
CallableStatement callableStatement = connection.prepareCall("{call rankBonus(?, ?, ?, ?, ?, ?, ?, ?)}"))
{
callableStatement.setInt(1, accountId);
callableStatement.setInt(2, bonusAmount.getCoins());
callableStatement.setInt(2, bonusAmount.getShards());
callableStatement.setInt(3, bonusAmount.getGems());
callableStatement.setInt(4, bonusAmount.getMythicalChests());
callableStatement.setInt(5, bonusAmount.getOmegaChests());
@ -329,10 +403,12 @@ public class BonusRepository extends RepositoryBase
});
}
public void attemptVoteBonus(final int accountId, final Callback<Pair<Boolean, Date>> result)
public void attemptVoteBonus(final int accountId, final boolean clans, final Callback<Pair<Boolean, Date>> result)
{
final int coins = 0;
final int serverId = 0;
final int shards = 0;
final int gems = 0;
final int gold = 1000;
final JavaPlugin plug = _manager.getPlugin();
@ -341,32 +417,62 @@ public class BonusRepository extends RepositoryBase
@Override
public void run()
{
if (clans)
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_clans_vote(?, ?, ?, ?, ?)}")) {
callableStatement.setInt(1, accountId);
callableStatement.setInt(2, serverId);
callableStatement.setInt(3, gold);
callableStatement.registerOutParameter(4, Types.BOOLEAN);
callableStatement.registerOutParameter(5, Types.DATE);
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, Types.BOOLEAN);
callableStatement.registerOutParameter(5, Types.DATE);
callableStatement.executeUpdate();
callableStatement.executeUpdate();
final boolean pass = callableStatement.getBoolean(4);
final Date date = callableStatement.getDate(5);
final boolean pass = callableStatement.getBoolean(4);
final Date date = callableStatement.getDate(5);
Bukkit.getScheduler().runTask(plug, new Runnable() {
@Override
public void run()
Bukkit.getScheduler().runTask(plug, new Runnable()
{
// _manager.Get(player).setVoteTime(date);
result.run(Pair.create(pass, date));
}
});
} catch (Exception e) {
e.printStackTrace();
result.run(null);
@Override
public void run()
{
// _manager.Get(player).setVoteTime(date);
result.run(Pair.create(pass, date));
}
});
} catch (Exception e) {
e.printStackTrace();
result.run(null);
}
}
else
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_vote(?, ?, ?, ?, ?)}")) {
callableStatement.setInt(1, accountId);
callableStatement.setInt(2, shards);
callableStatement.setInt(3, gems);
callableStatement.registerOutParameter(4, Types.BOOLEAN);
callableStatement.registerOutParameter(5, 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).setVoteTime(date);
result.run(Pair.create(pass, date));
}
});
} catch (Exception e) {
e.printStackTrace();
result.run(null);
}
}
}
});

View File

@ -0,0 +1,51 @@
package mineplex.core.bonuses;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class GoldAmount
{
private Map<Integer, Integer> _goldAmounts;
public GoldAmount()
{
_goldAmounts = new HashMap<>();
}
public Collection<Integer> getServerIds()
{
return _goldAmounts.keySet();
}
public Integer getGoldFor(Integer serverId)
{
return _goldAmounts.getOrDefault(serverId, 0);
}
public Integer getTotalGold()
{
Integer gold = 0;
for (Integer g : _goldAmounts.values())
{
gold += g;
}
return gold;
}
public void setGoldFor(Integer serverId, Integer gold)
{
_goldAmounts.put(serverId, gold);
}
public void addGold(Integer serverId, Integer gold)
{
_goldAmounts.put(serverId, getGoldFor(serverId) + gold);
}
public void clearGoldFor(Integer serverId)
{
_goldAmounts.remove(serverId);
}
}

View File

@ -311,4 +311,4 @@ public class AnimationCarl extends Animation
}
}
}
}
}

View File

@ -1,38 +1,50 @@
package mineplex.core.bonuses.gui;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.gui.buttons.*;
import mineplex.core.bonuses.gui.buttons.CarlSpinButton;
import mineplex.core.bonuses.gui.buttons.ClaimTipsButton;
import mineplex.core.bonuses.gui.buttons.DailyBonusButton;
import mineplex.core.bonuses.gui.buttons.FacebookButton;
import mineplex.core.bonuses.gui.buttons.PlayWireButton;
import mineplex.core.bonuses.gui.buttons.PollButton;
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.gui.buttons.RankBonusButton;
import mineplex.core.bonuses.gui.buttons.SpecificChannelButton;
import mineplex.core.bonuses.gui.buttons.TwitterButton;
import mineplex.core.bonuses.gui.buttons.VoteButton;
import mineplex.core.bonuses.gui.buttons.YoutubeButton;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gui.SimpleGui;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.reward.RewardManager;
import mineplex.core.thank.ThankManager;
import mineplex.core.youtube.YoutubeManager;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class BonusGui extends SimpleGui
{
private final int VOTE_SLOT = 40;
private final int RANK_BONUS_SLOT = 10;
private final int DAILY_BONUS_SLOT = 12;
private final int POLL_SLOT = 28;
private final int FACEBOOK_SLOT = 20;
private final int CLAIM_TIPS_SLOT = 30;
private final int POWER_PLAY_SLOT = 16;
private final int CARL_SPINNER_SLOT = 14;
private final int YOUTUBE_SLOT = 22;
private final int TWITTER_SLOT = 34;
private final int PLAY_WIRE_SLOT = 32;
private final int SPECIFIC_YOUTUBE_SLOT = 24;
//private final int VOTE_SLOT = 10;
private final int RANK_BONUS_SLOT = 11;
private final int DAILY_BONUS_SLOT = 13;
private final int POLL_SLOT = 15;
private final int FACEBOOK_SLOT = 19;
private final int CLAIM_TIPS_SLOT = 25;
private final int POWER_PLAY_SLOT = 21;
private final int CARL_SPINNER_SLOT = 23;
private final int YOUTUBE_SLOT = 29;
private final int TWITTER_SLOT = 33;
private final int PLAY_WIRE_SLOT = 31;
private static final int INV_SIZE = 45;
private static final int INV_SIZE = 54;
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager, PlayWireManager playWireManager)
{
super(plugin, player, player.getName() + "'s Bonuses", INV_SIZE);
//setItem(VOTE_SLOT, new VoteButton(plugin, player, this, manager));
setItem(VOTE_SLOT, new VoteButton(plugin, player, this, manager));
setItem(RANK_BONUS_SLOT, new RankBonusButton(getPlugin(), player, this, manager));
@ -53,6 +65,8 @@ public class BonusGui extends SimpleGui
setItem(CARL_SPINNER_SLOT, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
setItem(PLAY_WIRE_SLOT, new PlayWireButton(playWireManager, player));
setItem(SPECIFIC_YOUTUBE_SLOT, new SpecificChannelButton(player, youtubeManager));
}
@Override

View File

@ -82,4 +82,4 @@ public class CarlSpinButton implements GuiItem
return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false);
}
}
}

View File

@ -2,6 +2,22 @@ package mineplex.core.bonuses.gui.buttons;
import java.util.ArrayList;
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;
import mineplex.core.bonuses.BonusAmount;
import mineplex.core.bonuses.BonusClientData;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
@ -17,27 +33,9 @@ import mineplex.core.recharge.Recharge;
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;
@ -75,29 +73,39 @@ public class DailyBonusButton implements GuiItem, Listener
return;
}
if (isAvailable()) {
if (isAvailable() && canUse())
{
_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>() {
_bonusManager.attemptDailyBonus(getPlayer(), _bonusManager.ClansBonus ? _bonusManager.getClansDailyBonusAmount(_player) : _bonusManager.getDailyBonusAmount(_player), _bonusManager.ClansBonus, new Callback<Boolean>()
{
@Override
public void run(Boolean t)
{
if (t) {
if (t)
{
setItem();
if (getPlayer().getOpenInventory() != null) {
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 {
}
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) {
}
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 {
}
else
{
UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!"));
}
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
@ -105,8 +113,11 @@ public class DailyBonusButton implements GuiItem, Listener
getPlayer().closeInventory();
}
});
} else
}
else
{
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
}
return;
}
@ -125,7 +136,7 @@ public class DailyBonusButton implements GuiItem, Listener
String itemName;
byte data = 0;
if (isAvailable())
if (isAvailable() && canUse())
{
material = Material.CHEST;
itemName = C.cGreen + C.Bold + "Daily Reward";
@ -133,6 +144,14 @@ public class DailyBonusButton implements GuiItem, Listener
lore.add(" ");
lore.add(ChatColor.RESET + "Click to Claim!");
}
else if (!canUse())
{
material = Material.REDSTONE_BLOCK;
itemName = C.cRed + C.Bold + "Daily Reward";
lore.add(" ");
lore.add(ChatColor.RESET + "You must set your home server by joining a clan to claim this!");
}
else
{
material = Material.REDSTONE_BLOCK;
@ -143,37 +162,46 @@ public class DailyBonusButton implements GuiItem, Listener
}
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)
if (!_bonusManager.ClansBonus)
{
long lastBonus = _bonusManager.getLocalTime(client.getDailyTime().getTime());
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME);
BonusClientData client = _bonusManager.Get(_player);
BonusAmount bonusAmount = _bonusManager.getDailyBonusAmount(_player);
bonusAmount.addLore(lore);
lore.add(" ");
if (timeLeft > 0)
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)
{
lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT));
long lastBonus = BonusManager.getLocalTime(client.getDailyTime().getTime());
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.DAILY_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());
// }
}
else
{
lore.add(C.cYellow + "Home Server: " + C.cWhite + _bonusManager.getClansHomeServer(getPlayer()).getLeft());
lore.add(" ");
BonusAmount amount = _bonusManager.getClansDailyBonusAmount(_player);
amount.addLore(lore);
}
// 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);
}
@ -200,6 +228,16 @@ public class DailyBonusButton implements GuiItem, Listener
return (timeLeft() <= 0);
}
public boolean canUse()
{
if (!_bonusManager.ClansBonus)
{
return true;
}
return _bonusManager.getClansHomeServer(getPlayer()).getRight() != -1;
}
public Plugin getPlugin()
{
return _plugin;

View File

@ -97,7 +97,7 @@ public class PollButton extends SimpleGui implements GuiItem {
}
lore.add("");
BonusAmount amount = new BonusAmount();
amount.setCoins(_poll.getCoinReward());
amount.setShards(_poll.getCoinReward());
amount.setGems(_poll.getCoinReward());
amount.addLore(lore);
// lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
@ -142,7 +142,7 @@ public class PollButton extends SimpleGui implements GuiItem {
}
lore.add("");
BonusAmount amount = new BonusAmount();
amount.setCoins(_poll.getCoinReward());
amount.setShards(_poll.getCoinReward());
amount.setGems(_poll.getCoinReward());
amount.addLore(lore);

View File

@ -0,0 +1,114 @@
package mineplex.core.bonuses.gui.buttons;
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 mineplex.core.Managers;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.Pair;
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.gui.GuiItem;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.youtube.YoutubeManager;
public class SpecificChannelButton implements GuiItem
{
private final Player _player;
private final YoutubeManager _youtubeManager;
private Pair<String, String> _channel;
private ItemStack _item;
public SpecificChannelButton(Player player, YoutubeManager youtubeManager)
{
_player = player;
_youtubeManager = youtubeManager;
}
@Override
public void setup()
{
_channel = Managers.get(BonusManager.class).getSpecificCreator();
if (_youtubeManager.canSpecificYoutube(_player))
{
_item = new ItemBuilder(Material.APPLE)
.setTitle(C.cGreen + C.Bold + "Visit our featured creator " + C.cGoldB + _channel.getLeft())
.addLore(
C.cYellow + "Claim a Daily Reward",
C.cWhite + "by checking out the latest Video",
C.cWhite + "by " + C.cGold + _channel.getLeft() + C.cWhite + "!",
C.cWhite + " ",
C.cWhite + "Be sure and Subscribe if you",
C.cWhite + "enjoy their videos!",
" ",
C.cGreen + "Click to visit " + C.cGold + _channel.getLeft() + C.cGreen + " on YouTube!"
)
.build();
}
else
{
_item = new ItemBuilder(Material.APPLE)
.setTitle(C.cGreen + C.Bold + "Visit our featured creator " + C.cGoldB + _channel.getLeft())
.addLore(
C.cWhite + "Come back tomorrow for your",
C.cWhite + "Daily Reward!",
" ",
C.cWhite + "Check out the latest Video",
C.cWhite + "by " + C.cGold + _channel.getLeft() + C.cWhite + "!",
" ",
C.cWhite + "Be sure and Subscribe if you",
C.cWhite + "enjoy their videos!",
" ",
C.cGreen + "Click to visit " + C.cGold + _channel.getLeft() + C.cGreen + " on YouTube!"
)
.build();
}
}
@Override
public void close() {}
@Override
public void click(ClickType clickType)
{
if (!Recharge.Instance.use(_player, "Use Youtube Button", 1000, false, false))
{
return;
}
_player.closeInventory();
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
final String message;
if (_youtubeManager.canSpecificYoutube(_player))
{
message = "claim your Reward!";
_youtubeManager.attemptSpecificYoutube(_player, Managers.get(BonusManager.class).ClansBonus, Managers.get(BonusManager.class).getClansHomeServer(_player).getRight());
}
else
{
message = "visit " + _channel.getLeft() + " on YouTube!";
}
UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "=============================================");
UtilPlayer.message(_player, "");
new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, _channel.getRight()).sendToPlayer(_player);
new JsonMessage( " " + C.cGreen + C.Line + _channel.getRight().replace("?sub_confirmation=1", "")).click(ClickEvent.OPEN_URL, _channel.getRight()).sendToPlayer(_player);
UtilPlayer.message(_player, "");
UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "=============================================");
}
@Override
public ItemStack getObject()
{
return _item;
}
}

View File

@ -0,0 +1,213 @@
package mineplex.core.bonuses.gui.buttons;
import java.util.ArrayList;
import mineplex.core.bonuses.BonusAmount;
import mineplex.core.bonuses.BonusClientData;
import mineplex.core.bonuses.BonusManager;
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 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)
{
_bonusManager = bonusManager;
_player = player;
_plugin = plugin;
_gui = gui;
}
@Override
public void setup()
{
//TODO get url from db
_url = _bonusManager.getVoteLink();
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(), C.cGold + C.Bold + C.Strike + "=============================================");
UtilPlayer.message(getPlayer(), "");
new JsonMessage(" " + C.Bold + "Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
new JsonMessage( " " + C.cGreen + C.Line + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
UtilPlayer.message(getPlayer(), "");
UtilPlayer.message(getPlayer(), " Please be patient. Votes may take a few minutes to register.");
UtilPlayer.message(getPlayer(), "");
UtilPlayer.message(getPlayer(), C.cGold + C.Bold + C.Strike + "=============================================");
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() && canUse())
{
material = Material.JUKEBOX;
itemName = C.cGreen + C.Bold + "Vote for Mineplex";
lore.add(" ");
lore.add(ChatColor.RESET + "Click to Vote!");
}
else if (!canUse())
{
material = Material.REDSTONE_BLOCK;
itemName = C.cRed + C.Bold + "Vote for Mineplex";
lore.add(" ");
lore.add(ChatColor.RESET + "You must set your home server by joining a clan to receive voting rewards!");
}
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(" ");
if (!_bonusManager.ClansBonus)
{
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.getVoteMultiplier(client.getVoteStreak()) + "%");
if (client.getVoteTime() != null)
{
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_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());
// }
}
else
{
lore.add(C.cYellow + "Home Server: " + C.cWhite + _bonusManager.getClansHomeServer(getPlayer()).getLeft());
lore.add(" ");
BonusAmount amount = _bonusManager.getClansVoteBonusAmount(_player);
amount.addLore(lore);
}
_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;
return (timeLeft() <= 0);
}
public boolean canUse()
{
if (!_bonusManager.ClansBonus)
{
return true;
}
return _bonusManager.getClansHomeServer(getPlayer()).getRight() != -1;
}
public Plugin getPlugin()
{
return _plugin;
}
public Player getPlayer()
{
return _player;
}
public ItemRefresher getGui()
{
return _gui;
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.bonuses.gui.buttons;
import mineplex.core.Managers;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
@ -20,7 +22,7 @@ public class YoutubeButton implements GuiItem
.setTitle(C.cGreen + C.Bold + "Visit us on YouTube")
.addLore(
C.cWhite + "Come back tomorrow for your",
C.cWhite + "Daily 250 Shard Reward!",
C.cWhite + "Daily Reward!",
" ",
C.cWhite + "Check out the latest Video",
C.cWhite + "on the MineplexGames Channel!",
@ -34,7 +36,7 @@ public class YoutubeButton implements GuiItem
private static final ItemStack ENABLED_ICON = new ItemBuilder(Material.APPLE)
.setTitle(C.cGreen + C.Bold + "Visit us on YouTube")
.addLore(
C.cYellow + "Claim your Daily 250 Shard Reward",
C.cYellow + "Claim your Daily Reward",
C.cWhite + "by checking out the latest Video",
C.cWhite + "on the MineplexGames Channel!",
C.cWhite + " ",
@ -75,7 +77,7 @@ public class YoutubeButton implements GuiItem
if (_youtubeManager.canYoutube(_player))
{
message = "claim YouTube Prize!";
_youtubeManager.attemptYoutube(_player);
_youtubeManager.attemptYoutube(_player, Managers.get(BonusManager.class).ClansBonus, Managers.get(BonusManager.class).getClansHomeServer(_player).getRight());
}
else
{
@ -96,4 +98,4 @@ public class YoutubeButton implements GuiItem
{
return _youtubeManager.canYoutube(_player) ? ENABLED_ICON : DISABLED_ICON;
}
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.bonuses.redis;
import org.bukkit.entity.Player;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.UtilPlayer;
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, v.getRewardReceived(), v.isClans());
}
}
}

View File

@ -0,0 +1,34 @@
package mineplex.core.bonuses.redis;
import mineplex.serverdata.commands.ServerCommand;
public class VotifierCommand extends ServerCommand
{
private String _playerName;
private int _rewardReceived;
private boolean _clans;
public VotifierCommand(String playerName, int rewardReceived, boolean clans, String... targetServer)
{
super(targetServer);
_playerName = playerName;
_rewardReceived = rewardReceived;
_clans = clans;
}
public String getPlayerName()
{
return _playerName;
}
public int getRewardReceived()
{
return _rewardReceived;
}
public boolean isClans()
{
return _clans;
}
}

View File

@ -19,6 +19,7 @@ import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.donation.command.GemCommand;
import mineplex.core.donation.command.ShardCommand;
import mineplex.core.donation.gold.GoldRepository;
import mineplex.core.donation.repository.DonationRepository;
import mineplex.core.donation.repository.token.DonorTokenWrapper;
import mineplex.core.server.util.TransactionResponse;
@ -43,12 +44,14 @@ public class DonationManager extends MiniClientPlugin<Donor>
private final CoreClientManager _clientManager = require(CoreClientManager.class);
private final DonationRepository _repository;
private final GoldRepository _goldRepository;
private DonationManager()
{
super("Donation");
_repository = new DonationRepository();
_goldRepository = new GoldRepository();
UtilScheduler.runEvery(UpdateType.FAST, this::processCoinAttemptQueue);
}
@ -67,6 +70,11 @@ public class DonationManager extends MiniClientPlugin<Donor>
Get(event.getUniqueId()).loadToken(token.DonorToken);
}
public GoldRepository getGoldRepository()
{
return _goldRepository;
}
/**
* Adds an unknown sales package to the specified {@link Player}
@ -251,6 +259,20 @@ public class DonationManager extends MiniClientPlugin<Donor>
{
rewardCurrency(currency, client.getName(), client.getUniqueId(), reason, amount, updateTotal, callback);
}
/**
* Rewards a player a specific amount of a currency type - used by Votifier ONLY due to volatile playerName and playerUUID
* @param currency The type of currency to reward
* @param playerName The name of the player being rewarded
* @param playerUUID The UUID of the player being rewarded
* @param reason The reason for the currency being awarded
* @param amount The amount of currency being rewarded
* @param callback A callback to retrieve the success of the award
*/
public void rewardCurrency(GlobalCurrency currency, String playerName, UUID playerUUID, String reason, int amount, Consumer<Boolean> callback)
{
rewardCurrency(currency, playerName, playerUUID, reason, amount, true, callback);
}
// Private because volatile with playerName and playerUUID
private void rewardCurrency(GlobalCurrency currency, String playerName, UUID playerUUID, String reason, int amount, boolean updateTotal, Consumer<Boolean> callback)

View File

@ -1,87 +1,84 @@
package mineplex.game.clans.economy;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilServer;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class GoldRepository {
private static final String CREATE_TABLE = "CREATE TABLE clansGold (serverId int(11) not null, id int(11) not null, gold int not null, primary key (serverId, id), foreign key (serverId) references clanServer(id), foreign key (id) references accounts(id))";
private static final String UPDATE_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=gold+?";
private static final String SET_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=?";
private final int _serverId;
public GoldRepository(int serverId) {
_serverId = serverId;
}
public void rewardGold(final Callback<Boolean> callback, final int accountId, final int gold)
{
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD);
statement.setInt(1, _serverId);
statement.setInt(2, accountId);
statement.setInt(3, gold);
statement.setInt(4, gold);
statement.executeUpdate();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true));
}
} catch (SQLException e)
{
e.printStackTrace();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false));
}
}
});
}
public void setGold(final Callback<Boolean> callback, final int accountId, final int gold)
{
if (gold < 0)
{
throw new IllegalArgumentException("gold cannot be negative");
}
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD);
statement.setInt(1, _serverId);
statement.setInt(2, accountId);
statement.setInt(3, gold);
statement.setInt(4, gold);
statement.executeUpdate();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true));
}
} catch (SQLException e)
{
e.printStackTrace();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false));
}
}
});
}
}
package mineplex.core.donation.gold;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilServer;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class GoldRepository
{
private static final String CREATE_TABLE = "CREATE TABLE clansGold (serverId int(11) not null, id int(11) not null, gold int not null, primary key (serverId, id), foreign key (serverId) references clanServer(id), foreign key (id) references accounts(id))";
private static final String UPDATE_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=gold+?";
private static final String SET_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=?";
public GoldRepository() {}
public void rewardGold(final Callback<Boolean> callback, final int serverId, final int accountId, final int gold)
{
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD);
statement.setInt(1, serverId);
statement.setInt(2, accountId);
statement.setInt(3, gold);
statement.setInt(4, gold);
statement.executeUpdate();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true));
}
}
catch (SQLException e)
{
e.printStackTrace();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false));
}
}
});
}
public void setGold(final Callback<Boolean> callback, final int serverId, final int accountId, final int gold)
{
if (gold < 0)
{
throw new IllegalArgumentException("gold cannot be negative");
}
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD);
statement.setInt(1, serverId);
statement.setInt(2, accountId);
statement.setInt(3, gold);
statement.setInt(4, gold);
statement.executeUpdate();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true));
}
}
catch (SQLException e)
{
e.printStackTrace();
if (callback != null)
{
Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false));
}
}
});
}
}

View File

@ -17,7 +17,6 @@ import mineplex.core.Managers;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
@ -97,12 +96,12 @@ public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
final PlayWireClientData client = Get(player);
if (client == null || client.getAccountId() == -1)
{
player.sendMessage(ResponseType.UNFILLED.getMessage());
player.sendMessage(ResponseType.UNFILLED.getMessage(Managers.get(BonusManager.class).getCreeperName()));
return;
}
if (!canRedeemTickets(client))
{
player.sendMessage(ResponseType.UNCOUNTED.getMessage(UtilTime.MakeStr(client.getTicketRefresh() - System.currentTimeMillis())));
player.sendMessage(ResponseType.UNCOUNTED.getMessage(Managers.get(BonusManager.class).getCreeperName(), UtilTime.MakeStr(client.getTicketRefresh() - System.currentTimeMillis())));
return;
}
@ -150,7 +149,7 @@ public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
}
});
Managers.get(BonusManager.class).addPendingExplosion(player, player.getName());
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage(client.getTicketsRemaining() + "")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage(Managers.get(BonusManager.class).getCreeperName(), client.getTicketsRemaining() + "")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
});
}
@ -179,7 +178,7 @@ public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
}
else
{
player.sendMessage(response.getMessage());
player.sendMessage(response.getMessage(Managers.get(BonusManager.class).getCreeperName()));
}
}

View File

@ -7,10 +7,10 @@ import mineplex.core.common.util.F;
*/
public enum ResponseType
{
COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! You have " + F.elem("%elem%") + " tickets remaining for the current 24 hour period!")),
UNCOUNTED(F.main("Carl", "You already received your " + F.elem("5 Carl Spin Tickets") + " for the current 24 hour period! Your available tickets will refresh in " + F.elem("%elem%") + "!")),
BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")),
UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it ssssorted ASAP. Try again in a few minutessss!")),;
COUNTED(F.main("%creeper%", "Rewarded " + F.elem("1 Spin Ticket") + " for watching the Ad! You have " + F.elem("%elem%") + " tickets remaining for the current 24 hour period!")),
UNCOUNTED(F.main("%creeper%", "You already received your " + F.elem("5 Spin Tickets") + " for the current 24 hour period! Your available tickets will refresh in " + F.elem("%elem%") + "!")),
BLOCKED(F.main("%creeper%", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")),
UNFILLED(F.main("%creeper%", "Ssssomething went wrong with the Ad, we'll get it ssssorted ASAP. Try again in a few minutessss!")),;
private String _message;
@ -19,9 +19,10 @@ public enum ResponseType
_message = message;
}
public String getMessage(String... elements)
public String getMessage(String creeperName, String... elements)
{
String message = _message;
message = message.replaceFirst("%creeper%", creeperName);
if (elements.length > 0)
{
for (int i = 0; i < elements.length; i++)

View File

@ -154,7 +154,9 @@ import mineplex.core.pet.PetType;
import mineplex.core.powerplayclub.PowerPlayData.SubscriptionDuration;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.rewards.ChestReward;
import mineplex.core.reward.rewards.ExperienceReward;
import mineplex.core.reward.rewards.GameAmplifierReward;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.PowerPlayReward;
@ -163,6 +165,7 @@ import mineplex.core.reward.rewards.RuneAmplifierReward;
import mineplex.core.reward.rewards.SpinTicketReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import mineplex.core.stats.StatsManager;
import mineplex.core.treasure.TreasureType;
public class RewardManager
@ -175,6 +178,7 @@ public class RewardManager
private InventoryManager _inventoryManager;
private GadgetManager _gadgetManager;
private PetManager _petManager;
private StatsManager _statsManager;
private final double _gadgetMultiplier = 1;
@ -188,7 +192,7 @@ public class RewardManager
private int _legendaryShards = 5000;
public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
PetManager petManager, GadgetManager gadgetManager)
PetManager petManager, GadgetManager gadgetManager, StatsManager statsManager)
{
_rewardPools = new EnumMap<>(RewardPool.Type.class);
_random = new Random();
@ -203,6 +207,7 @@ public class RewardManager
_inventoryManager = inventoryManager;
_gadgetManager = gadgetManager;
_petManager = petManager;
_statsManager = statsManager;
_commonAmmoMin *= _gadgetMultiplier;
_commonAmmoMax *= _gadgetMultiplier;
@ -223,7 +228,8 @@ public class RewardManager
{
RewardRarity rarity = RewardRarity.COMMON;
addReward(Type.CARL_SPINNER, new TreasureShardReward(_clientManager, _donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 25, rarity));
addReward(Type.CARL_SPINNER, new GemReward(_donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 25, 0, rarity));
addReward(Type.CARL_SPINNER, new ExperienceReward(_statsManager, getAmmoMin(rarity)*5, getAmmoMax(rarity)*5, 25, 0, rarity));
//Normal Gadgets
addInventoryReward(Type.NORMAL, getGadget(ItemBatGun.class), rarity, 10, getShards(rarity), 4, 10);
@ -252,7 +258,8 @@ public class RewardManager
{
RewardRarity rarity = RewardRarity.UNCOMMON;
addReward(Type.CARL_SPINNER, new TreasureShardReward(_clientManager, _donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 1200, rarity));
addReward(Type.CARL_SPINNER, new GemReward(_donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 1200, 0, rarity));
addReward(Type.CARL_SPINNER, new ExperienceReward(_statsManager, getAmmoMin(rarity)*5, getAmmoMax(rarity)*5, 1200, 0, rarity));
//Gadgets
addInventoryReward(Type.NORMAL, getGadget(ItemBatGun.class), rarity, 250, 0, 20, 40);
@ -336,7 +343,8 @@ public class RewardManager
{
RewardRarity rarity = RewardRarity.RARE;
addReward(Type.CARL_SPINNER, new TreasureShardReward(_clientManager, _donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 150, rarity));
addReward(Type.CARL_SPINNER, new GemReward(_donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 150, 0, rarity));
addReward(Type.CARL_SPINNER, new ExperienceReward(_statsManager, getAmmoMin(rarity)*5, getAmmoMax(rarity)*5, 150, 0, rarity));
//Morphs
addGadget(Type.NORMAL, getGadget(MorphVillager.class), rarity, 83);
@ -562,7 +570,8 @@ public class RewardManager
{
RewardRarity rarity = RewardRarity.LEGENDARY;
addReward(Type.CARL_SPINNER, new TreasureShardReward(_clientManager, _donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 10, rarity));
addReward(Type.CARL_SPINNER, new GemReward(_donationManager, getAmmoMin(rarity), getAmmoMax(rarity), 10, 0, rarity));
addReward(Type.CARL_SPINNER, new ExperienceReward(_statsManager, getAmmoMin(rarity)*5, getAmmoMax(rarity)*5, 10, 0, rarity));
//REGULAR

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
@ -116,13 +115,6 @@ public class RewardPool
}
}
}
if (this == Type.CARL_SPINNER)
{
if (reward instanceof GemReward)
{
return false;
}
}
return true;
}

View File

@ -5,19 +5,31 @@ import java.time.LocalDate;
public class YoutubeClient
{
private LocalDate _clickDate;
private LocalDate _specificDate;
public YoutubeClient(LocalDate date)
public YoutubeClient(LocalDate date, LocalDate specificDate)
{
this._clickDate = date;
_clickDate = date;
_specificDate = specificDate;
}
public LocalDate getClickDate()
{
return _clickDate;
}
public LocalDate getSpecificDate()
{
return _specificDate;
}
public void setClickDate(LocalDate date)
{
_clickDate = date;
}
}
public void setSpecificDate(LocalDate date)
{
_specificDate = date;
}
}

View File

@ -1,15 +1,5 @@
package mineplex.core.youtube;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
@ -17,6 +7,18 @@ import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
{
private static final int REWARD_MESSAGE_DELAY_SECONDS = 30;
@ -28,6 +30,31 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
super("YoutubeManager", plugin, clientManager);
_donationManager = donationManager;
_repository = new YoutubeRepository(this);
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor()
{
@Override
public String getName()
{
return "specific-youtuber-click";
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
{
boolean hasRow = resultSet.next();
if (hasRow)
{
YoutubeManager.this.Get(uuid).setSpecificDate(resultSet.getDate(1).toLocalDate());
}
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT clicktime FROM specificYoutube WHERE accountId=" + accountId + ";";
}
});
}
public boolean canYoutube(Player player)
@ -45,19 +72,72 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
return !date.equals(utc);
}
public boolean canSpecificYoutube(Player player)
{
YoutubeClient client = Get(player);
LocalDate date = client.getSpecificDate();
public void attemptYoutube(Player player)
if (date == null)
{
return true;
}
ZonedDateTime utcZoned = ZonedDateTime.now(ZoneOffset.UTC);
LocalDate utc = utcZoned.toLocalDate();
return !date.equals(utc);
}
public void attemptYoutube(Player player, boolean clans, final int clansServerId)
{
if (!canYoutube(player))
{
return;
}
YoutubeClient client = Get(player);
final int accountId = getClientManager().getAccountId(player);
client.setClickDate(ZonedDateTime.now(ZoneOffset.UTC).toLocalDate());
_repository.attemptYoutube(player, client, () ->
{
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "YouTube", 250);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
if (clans && clansServerId != -1)
{
_donationManager.getGoldRepository().rewardGold(success ->
{
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Gold") + " on your home server for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
}, clansServerId, accountId, 250);
}
else
{
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "YouTube", 250);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
}
});
}
public void attemptSpecificYoutube(Player player, final boolean clans, final int clansServerId)
{
if (!canYoutube(player))
{
return;
}
YoutubeClient client = Get(player);
final int accountId = getClientManager().getAccountId(player);
client.setSpecificDate(ZonedDateTime.now(ZoneOffset.UTC).toLocalDate());
_repository.attemptSpecificYoutube(player, client, () ->
{
if (clans && clansServerId != -1)
{
_donationManager.getGoldRepository().rewardGold(success ->
{
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Gold") + " on your home server for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
}, clansServerId, accountId, 250);
}
else
{
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "YouTube", 250);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
}
});
}
@ -66,9 +146,9 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
{
boolean hasRow = resultSet.next();
if (hasRow)
Set(uuid, new YoutubeClient(resultSet.getDate(1).toLocalDate()));
Set(uuid, new YoutubeClient(resultSet.getDate(1).toLocalDate(), null));
else
Set(uuid, new YoutubeClient(null));
Set(uuid, new YoutubeClient(null, null));
}
@Override
@ -80,6 +160,6 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
@Override
protected YoutubeClient addPlayer(UUID uuid)
{
return new YoutubeClient(null);
return new YoutubeClient(null, null);
}
}
}

View File

@ -39,5 +39,26 @@ public class YoutubeRepository
}
});
}
public void attemptSpecificYoutube(Player player, YoutubeClient client, Runnable runnable)
{
int accountId = _manager.getClientManager().Get(player).getAccountId();
}
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), () ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("REPLACE INTO specificYoutube (accountId, clicktime) VALUES (?, ?)");
statement.setInt(1, accountId);
statement.setDate(2, Date.valueOf(client.getSpecificDate()));
statement.executeUpdate();
runnable.run();
}
catch (SQLException e)
{
e.printStackTrace();
}
});
}
}

View File

@ -81,6 +81,19 @@ public class Routines {
p.execute(configuration);
return p;
}
/**
* Call <code>Account.check_clans_daily</code>
*/
public static mineplex.database.routines.Check_clans_daily callCheckClansDaily(org.jooq.Configuration configuration, java.lang.Integer accountId_in, java.lang.Integer serverId_in, java.lang.Integer goldChange) {
mineplex.database.routines.Check_clans_daily p = new mineplex.database.routines.Check_clans_daily();
p.setAccountId_in(accountId_in);
p.setServerId_in(serverId_in);
p.setGoldChange(goldChange);
p.execute(configuration);
return p;
}
/**
* Call <code>Account.check_giveaway</code>
@ -131,6 +144,19 @@ public class Routines {
p.execute(configuration);
return p;
}
/**
* Call <code>Account.check_clans_vote</code>
*/
public static mineplex.database.routines.Check_clans_vote callCheckClansVote(org.jooq.Configuration configuration, java.lang.Integer accountId_in, java.lang.Integer serverId_in, java.lang.Integer goldChange) {
mineplex.database.routines.Check_clans_vote p = new mineplex.database.routines.Check_clans_vote();
p.setAccountId_in(accountId_in);
p.setServerId_in(serverId_in);
p.setGoldChange(goldChange);
p.execute(configuration);
return p;
}
/**
* Call <code>Account.claimThank</code>

View File

@ -0,0 +1,93 @@
/**
* This class is generated by jOOQ
*/
package mineplex.database.routines;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.5.2"
},
comments = "This class is generated by jOOQ"
)
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Check_clans_daily extends org.jooq.impl.AbstractRoutine<java.lang.Void> implements java.io.Serializable, java.lang.Cloneable {
private static final long serialVersionUID = -1266580733;
/**
* The parameter <code>Account.check_clans_daily.accountId_in</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> accountId_in = createParameter("accountId_in", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.check_clans_daily.serverId_in</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> serverId_in = createParameter("serverId_in", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.check_clans_daily.goldChange</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> goldChange = createParameter("goldChange", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.check_clans_daily.pass</code>.
*/
public static final org.jooq.Parameter<java.lang.Byte> pass = createParameter("pass", org.jooq.impl.SQLDataType.TINYINT, false);
/**
* The parameter <code>Account.check_clans_daily.outTime</code>.
*/
public static final org.jooq.Parameter<java.sql.Timestamp> outTime = createParameter("outTime", org.jooq.impl.SQLDataType.TIMESTAMP, false);
/**
* Create a new routine call instance
*/
public Check_clans_daily() {
super("check_clans_daily", mineplex.database.Account.Account);
addInParameter(accountId_in);
addInParameter(serverId_in);
addInParameter(goldChange);
addOutParameter(pass);
addOutParameter(outTime);
}
/**
* Set the <code>accountId_in</code> parameter IN value to the routine
*/
public void setAccountId_in(java.lang.Integer value) {
setValue(mineplex.database.routines.Check_clans_daily.accountId_in, value);
}
/**
* Set the <code>serverId_in</code> parameter IN value to the routine
*/
public void setServerId_in(java.lang.Integer value) {
setValue(mineplex.database.routines.Check_clans_daily.serverId_in, value);
}
/**
* Set the <code>goldChange</code> parameter IN value to the routine
*/
public void setGoldChange(java.lang.Integer value) {
setValue(mineplex.database.routines.Check_clans_daily.goldChange, value);
}
/**
* Get the <code>pass</code> parameter OUT value from the routine
*/
public java.lang.Byte getPass() {
return getValue(pass);
}
/**
* Get the <code>outTime</code> parameter OUT value from the routine
*/
public java.sql.Timestamp getOutTime() {
return getValue(outTime);
}
}

View File

@ -0,0 +1,93 @@
/**
* This class is generated by jOOQ
*/
package mineplex.database.routines;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.5.2"
},
comments = "This class is generated by jOOQ"
)
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Check_clans_vote extends org.jooq.impl.AbstractRoutine<java.lang.Void> implements java.io.Serializable, java.lang.Cloneable {
private static final long serialVersionUID = 2035299030;
/**
* The parameter <code>Account.check_clans_vote.accountId_in</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> accountId_in = createParameter("accountId_in", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.check_clans_vote.serverId_in</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> serverId_in = createParameter("serverId_in", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.check_clans_vote.goldChange</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> goldChange = createParameter("goldChange", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.check_clans_vote.pass</code>.
*/
public static final org.jooq.Parameter<java.lang.Byte> pass = createParameter("pass", org.jooq.impl.SQLDataType.TINYINT, false);
/**
* The parameter <code>Account.check_clans_vote.outTime</code>.
*/
public static final org.jooq.Parameter<java.sql.Date> outTime = createParameter("outTime", org.jooq.impl.SQLDataType.DATE, false);
/**
* Create a new routine call instance
*/
public Check_clans_vote() {
super("check_clans_vote", mineplex.database.Account.Account);
addInParameter(accountId_in);
addInParameter(serverId_in);
addInParameter(goldChange);
addOutParameter(pass);
addOutParameter(outTime);
}
/**
* Set the <code>accountId_in</code> parameter IN value to the routine
*/
public void setAccountId_in(java.lang.Integer value) {
setValue(mineplex.database.routines.Check_clans_daily.accountId_in, value);
}
/**
* Set the <code>serverId_in</code> parameter IN value to the routine
*/
public void setServerId_in(java.lang.Integer value) {
setValue(mineplex.database.routines.Check_clans_daily.serverId_in, value);
}
/**
* Set the <code>goldChange</code> parameter IN value to the routine
*/
public void setGoldChange(java.lang.Integer value) {
setValue(mineplex.database.routines.Check_clans_daily.goldChange, value);
}
/**
* Get the <code>pass</code> parameter OUT value from the routine
*/
public java.lang.Byte getPass() {
return getValue(pass);
}
/**
* Get the <code>outTime</code> parameter OUT value from the routine
*/
public java.sql.Date getOutTime() {
return getValue(outTime);
}
}

View File

@ -40,6 +40,11 @@ public class Bonus extends org.jooq.impl.TableImpl<mineplex.database.tables.reco
* The column <code>Account.bonus.dailytime</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.sql.Timestamp> dailytime = createField("dailytime", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
/**
* The column <code>Account.bonus.clansdailytime</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.sql.Timestamp> clansdailytime = createField("clansdailytime", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
/**
* The column <code>Account.bonus.ranktime</code>.
@ -50,6 +55,11 @@ public class Bonus extends org.jooq.impl.TableImpl<mineplex.database.tables.reco
* The column <code>Account.bonus.votetime</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.sql.Date> votetime = createField("votetime", org.jooq.impl.SQLDataType.DATE, this, "");
/**
* The column <code>Account.bonus.clansvotetime</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.BonusRecord, java.sql.Date> clansvotetime = createField("clansvotetime", org.jooq.impl.SQLDataType.DATE, this, "");
/**
* The column <code>Account.bonus.dailyStreak</code>.

View File

@ -14,7 +14,7 @@ package mineplex.database.tables.records;
comments = "This class is generated by jOOQ"
)
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.BonusRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record9<java.lang.Integer, java.sql.Timestamp, java.sql.Date, java.sql.Date, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer> {
public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.BonusRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record11<java.lang.Integer, java.sql.Timestamp, java.sql.Timestamp, java.sql.Date, java.sql.Date, java.sql.Date, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer> {
private static final long serialVersionUID = -785434679;
@ -45,103 +45,131 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
public java.sql.Timestamp getDailytime() {
return (java.sql.Timestamp) getValue(1);
}
/**
* Setter for <code>Account.bonus.clansdailytime</code>.
*/
public void setClansDailytime(java.sql.Timestamp value) {
setValue(2, value);
}
/**
* Getter for <code>Account.bonus.clansdailytime</code>.
*/
public java.sql.Timestamp getClansDailytime() {
return (java.sql.Timestamp) getValue(2);
}
/**
* Setter for <code>Account.bonus.ranktime</code>.
*/
public void setRanktime(java.sql.Date value) {
setValue(2, value);
setValue(3, value);
}
/**
* Getter for <code>Account.bonus.ranktime</code>.
*/
public java.sql.Date getRanktime() {
return (java.sql.Date) getValue(2);
return (java.sql.Date) getValue(3);
}
/**
* Setter for <code>Account.bonus.votetime</code>.
*/
public void setVotetime(java.sql.Date value) {
setValue(3, value);
setValue(4, value);
}
/**
* Getter for <code>Account.bonus.votetime</code>.
*/
public java.sql.Date getVotetime() {
return (java.sql.Date) getValue(3);
return (java.sql.Date) getValue(4);
}
/**
* Setter for <code>Account.bonus.clansvotetime</code>.
*/
public void setClansVotetime(java.sql.Date value) {
setValue(5, value);
}
/**
* Getter for <code>Account.bonus.votetime</code>.
*/
public java.sql.Date getClansVotetime() {
return (java.sql.Date) getValue(5);
}
/**
* Setter for <code>Account.bonus.dailyStreak</code>.
*/
public void setDailyStreak(java.lang.Integer value) {
setValue(4, value);
setValue(6, value);
}
/**
* Getter for <code>Account.bonus.dailyStreak</code>.
*/
public java.lang.Integer getDailyStreak() {
return (java.lang.Integer) getValue(4);
return (java.lang.Integer) getValue(6);
}
/**
* Setter for <code>Account.bonus.maxDailyStreak</code>.
*/
public void setMaxDailyStreak(java.lang.Integer value) {
setValue(5, value);
setValue(7, value);
}
/**
* Getter for <code>Account.bonus.maxDailyStreak</code>.
*/
public java.lang.Integer getMaxDailyStreak() {
return (java.lang.Integer) getValue(5);
return (java.lang.Integer) getValue(7);
}
/**
* Setter for <code>Account.bonus.voteStreak</code>.
*/
public void setVoteStreak(java.lang.Integer value) {
setValue(6, value);
setValue(8, value);
}
/**
* Getter for <code>Account.bonus.voteStreak</code>.
*/
public java.lang.Integer getVoteStreak() {
return (java.lang.Integer) getValue(6);
return (java.lang.Integer) getValue(8);
}
/**
* Setter for <code>Account.bonus.maxVoteStreak</code>.
*/
public void setMaxVoteStreak(java.lang.Integer value) {
setValue(7, value);
setValue(9, value);
}
/**
* Getter for <code>Account.bonus.maxVoteStreak</code>.
*/
public java.lang.Integer getMaxVoteStreak() {
return (java.lang.Integer) getValue(7);
return (java.lang.Integer) getValue(9);
}
/**
* Setter for <code>Account.bonus.tickets</code>.
*/
public void setTickets(java.lang.Integer value) {
setValue(8, value);
setValue(10, value);
}
/**
* Getter for <code>Account.bonus.tickets</code>.
*/
public java.lang.Integer getTickets() {
return (java.lang.Integer) getValue(8);
return (java.lang.Integer) getValue(10);
}
// -------------------------------------------------------------------------
@ -164,16 +192,16 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
* {@inheritDoc}
*/
@Override
public org.jooq.Row9<java.lang.Integer, java.sql.Timestamp, java.sql.Date, java.sql.Date, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer> fieldsRow() {
return (org.jooq.Row9) super.fieldsRow();
public org.jooq.Row11<java.lang.Integer, java.sql.Timestamp, java.sql.Timestamp, java.sql.Date, java.sql.Date, java.sql.Date, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer> fieldsRow() {
return (org.jooq.Row11) super.fieldsRow();
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Row9<java.lang.Integer, java.sql.Timestamp, java.sql.Date, java.sql.Date, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer> valuesRow() {
return (org.jooq.Row9) super.valuesRow();
public org.jooq.Row11<java.lang.Integer, java.sql.Timestamp, java.sql.Timestamp, java.sql.Date, java.sql.Date, java.sql.Date, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer> valuesRow() {
return (org.jooq.Row11) super.valuesRow();
}
/**
@ -191,13 +219,13 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
public org.jooq.Field<java.sql.Timestamp> field2() {
return mineplex.database.tables.Bonus.bonus.dailytime;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.sql.Date> field3() {
return mineplex.database.tables.Bonus.bonus.ranktime;
public org.jooq.Field<java.sql.Timestamp> field3() {
return mineplex.database.tables.Bonus.bonus.clansdailytime;
}
/**
@ -205,23 +233,23 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public org.jooq.Field<java.sql.Date> field4() {
return mineplex.database.tables.Bonus.bonus.ranktime;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.sql.Date> field5() {
return mineplex.database.tables.Bonus.bonus.votetime;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field5() {
return mineplex.database.tables.Bonus.bonus.dailyStreak;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field6() {
return mineplex.database.tables.Bonus.bonus.maxDailyStreak;
public org.jooq.Field<java.sql.Date> field6() {
return mineplex.database.tables.Bonus.bonus.clansvotetime;
}
/**
@ -229,7 +257,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public org.jooq.Field<java.lang.Integer> field7() {
return mineplex.database.tables.Bonus.bonus.voteStreak;
return mineplex.database.tables.Bonus.bonus.dailyStreak;
}
/**
@ -237,7 +265,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public org.jooq.Field<java.lang.Integer> field8() {
return mineplex.database.tables.Bonus.bonus.maxVoteStreak;
return mineplex.database.tables.Bonus.bonus.maxDailyStreak;
}
/**
@ -245,6 +273,22 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public org.jooq.Field<java.lang.Integer> field9() {
return mineplex.database.tables.Bonus.bonus.voteStreak;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field10() {
return mineplex.database.tables.Bonus.bonus.maxVoteStreak;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field11() {
return mineplex.database.tables.Bonus.bonus.tickets;
}
@ -263,13 +307,13 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
public java.sql.Timestamp value2() {
return getDailytime();
}
/**
* {@inheritDoc}
*/
@Override
public java.sql.Date value3() {
return getRanktime();
public java.sql.Timestamp value3() {
return getClansDailytime();
}
/**
@ -277,23 +321,23 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public java.sql.Date value4() {
return getRanktime();
}
/**
* {@inheritDoc}
*/
@Override
public java.sql.Date value5() {
return getVotetime();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Integer value5() {
return getDailyStreak();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Integer value6() {
return getMaxDailyStreak();
public java.sql.Date value6() {
return getClansVotetime();
}
/**
@ -301,7 +345,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public java.lang.Integer value7() {
return getVoteStreak();
return getDailyStreak();
}
/**
@ -309,7 +353,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public java.lang.Integer value8() {
return getMaxVoteStreak();
return getMaxDailyStreak();
}
/**
@ -317,6 +361,22 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public java.lang.Integer value9() {
return getVoteStreak();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Integer value10() {
return getMaxVoteStreak();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Integer value11() {
return getTickets();
}
@ -337,13 +397,13 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
setDailytime(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public BonusRecord value3(java.sql.Date value) {
setRanktime(value);
public BonusRecord value3(java.sql.Timestamp value) {
setClansDailytime(value);
return this;
}
@ -352,25 +412,25 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public BonusRecord value4(java.sql.Date value) {
setRanktime(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public BonusRecord value5(java.sql.Date value) {
setVotetime(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public BonusRecord value5(java.lang.Integer value) {
setDailyStreak(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public BonusRecord value6(java.lang.Integer value) {
setMaxDailyStreak(value);
public BonusRecord value6(java.sql.Date value) {
setClansVotetime(value);
return this;
}
@ -379,7 +439,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public BonusRecord value7(java.lang.Integer value) {
setVoteStreak(value);
setDailyStreak(value);
return this;
}
@ -388,7 +448,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public BonusRecord value8(java.lang.Integer value) {
setMaxVoteStreak(value);
setMaxDailyStreak(value);
return this;
}
@ -397,6 +457,24 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
*/
@Override
public BonusRecord value9(java.lang.Integer value) {
setVoteStreak(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public BonusRecord value10(java.lang.Integer value) {
setMaxVoteStreak(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public BonusRecord value11(java.lang.Integer value) {
setTickets(value);
return this;
}
@ -405,7 +483,7 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
* {@inheritDoc}
*/
@Override
public BonusRecord values(java.lang.Integer value1, java.sql.Timestamp value2, java.sql.Date value3, java.sql.Date value4, java.lang.Integer value5, java.lang.Integer value6, java.lang.Integer value7, java.lang.Integer value8, java.lang.Integer value9) {
public BonusRecord values(java.lang.Integer value1, java.sql.Timestamp value2, java.sql.Timestamp value3, java.sql.Date value4, java.sql.Date value5, java.sql.Date value6, java.lang.Integer value7, java.lang.Integer value8, java.lang.Integer value9, java.lang.Integer value10, java.lang.Integer value11) {
return this;
}
@ -423,17 +501,19 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.data
/**
* Create a detached, initialised BonusRecord
*/
public BonusRecord(java.lang.Integer accountId, java.sql.Timestamp dailytime, java.sql.Date ranktime, java.sql.Date votetime, java.lang.Integer dailyStreak, java.lang.Integer maxDailyStreak, java.lang.Integer voteStreak, java.lang.Integer maxVoteStreak, java.lang.Integer tickets) {
public BonusRecord(java.lang.Integer accountId, java.sql.Timestamp dailytime, java.sql.Timestamp clansdailytime, java.sql.Date ranktime, java.sql.Date votetime, java.sql.Date clansvotetime, java.lang.Integer dailyStreak, java.lang.Integer maxDailyStreak, java.lang.Integer voteStreak, java.lang.Integer maxVoteStreak, java.lang.Integer tickets) {
super(mineplex.database.tables.Bonus.bonus);
setValue(0, accountId);
setValue(1, dailytime);
setValue(2, ranktime);
setValue(3, votetime);
setValue(4, dailyStreak);
setValue(5, maxDailyStreak);
setValue(6, voteStreak);
setValue(7, maxVoteStreak);
setValue(8, tickets);
setValue(2, clansdailytime);
setValue(3, ranktime);
setValue(4, votetime);
setValue(5, clansvotetime);
setValue(6, dailyStreak);
setValue(7, maxDailyStreak);
setValue(8, voteStreak);
setValue(9, maxVoteStreak);
setValue(10, tickets);
}
}

View File

@ -4,6 +4,7 @@ import mineplex.core.common.currency.Currency;
import mineplex.core.common.util.C;
import org.bukkit.Material;
public class ClansCurrency {
public class ClansCurrency
{
public static final Currency GOLD = new Currency("Gold", "Gold", C.cGold, Material.GOLD_NUGGET);
}

View File

@ -4,8 +4,6 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.bukkit.entity.Player;
import mineplex.serverdata.data.Data;
public class GemTransfer implements Data

View File

@ -1,12 +1,12 @@
package mineplex.game.clans.economy;
import mineplex.core.account.CoreClient;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.entity.Player;
public class GoldCommand extends CommandBase<GoldManager>
{
@ -38,7 +38,9 @@ public class GoldCommand extends CommandBase<GoldManager>
Plugin.getClientManager().loadClientByName(targetName, client ->
{
if (client != null)
{
rewardGold(caller, null, targetName, client.getAccountId(), goldString);
}
else
{
UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName)));

View File

@ -4,15 +4,18 @@ public class GoldData
{
private int balance;
public void addBalance(int amount) {
public void addBalance(int amount)
{
balance += amount;
}
public void setBalance(int amount) {
public void setBalance(int amount)
{
balance = amount;
}
public int getBalance() {
public int getBalance()
{
return balance;
}
}
}

View File

@ -1,17 +1,14 @@
package mineplex.game.clans.economy;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.*;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansDataAccessLayer;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.shop.bank.BankShop;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material;
@ -28,9 +25,22 @@ import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.util.Vector;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansDataAccessLayer;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.shop.bank.BankShop;
public class GoldManager extends MiniDbClientPlugin<GoldData>
{
@ -53,8 +63,6 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
private Map<Player, Integer> _playerPickupMap;
private BankShop _bankShop;
private final GoldRepository _repository;
public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager, ClansDataAccessLayer dataAccessLayer)
{
super("Clans Gold", plugin.getPlugin(), clientManager);
@ -66,7 +74,6 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
_itemSet = new HashSet<Item>();
_playerPickupMap = new HashMap<Player, Integer>();
_bankShop = new BankShop(plugin, clientManager, donationManager);
_repository = new GoldRepository(_serverId);
}
@Override
@ -319,43 +326,46 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
public void setGold(final Callback<Boolean> callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
{
_repository.setGold(new Callback<Boolean>()
_donationManager.getGoldRepository().setGold(success ->
{
public void run(Boolean success)
if (success)
{
if (success)
if (updateTotal)
{
if (updateTotal)
{
GoldData data = Get(name);
GoldData data = Get(name);
if (data != null)
{
data.setBalance(amount);
}
if (data != null)
{
data.setBalance(amount);
}
}
else
{
System.out.println("SET GOLD FAILED...");
}
if (callback != null)
callback.run(success);
}
}, accountId, amount);
else
{
System.out.println("SET GOLD FAILED...");
}
if (callback != null)
{
callback.run(success);
}
}, _serverId, accountId, amount);
}
public void addGold(Player player, int amount)
{
if (amount >= 0)
{
rewardGold(null, player, amount, true);
}
}
public void deductGold(Callback<Boolean> resultCallback, Player player, int amount)
{
if (amount > 0)
{
rewardGold(resultCallback, player, -amount, true);
}
}
public void rewardGold(final Callback<Boolean> callback, final Player player, final int amount, final boolean updateTotal)
@ -374,33 +384,31 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
return;
}
_repository.rewardGold(new Callback<Boolean>()
_donationManager.getGoldRepository().rewardGold(success ->
{
public void run(Boolean success)
if (success)
{
if (success)
if (updateTotal)
{
if (updateTotal)
{
GoldData data = Get(name);
GoldData data = Get(name);
if (data != null)
{
data.addBalance(amount);
}
if (data != null)
{
data.addBalance(amount);
}
}
else
{
System.out.println("REWARD GOLD FAILED...");
}
if (callback != null)
callback.run(success);
}
}, accountId, amount);
}
else
{
System.out.println("REWARD GOLD FAILED...");
}
if (callback != null)
{
callback.run(success);
}
}, _serverId, accountId, amount);
}
@Override
public String getQuery(int accountId, String uuid, String name)
@ -440,4 +448,4 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
{
return new GoldData();
}
}
}

View File

@ -9,7 +9,8 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
public class GoldPurchaseProcessor implements ConfirmationProcessor {
public class GoldPurchaseProcessor implements ConfirmationProcessor
{
private final Player _player;
private final int _price;
private final GoldManager _goldManager;
@ -24,7 +25,8 @@ public class GoldPurchaseProcessor implements ConfirmationProcessor {
}
@Override
public void init(Inventory inventory) {
public void init(Inventory inventory)
{
inventory.setItem(4, new ItemBuilder(ClansCurrency.GOLD.getDisplayMaterial()).setTitle(ClansCurrency.GOLD.getPrefix()).addLore(C.cGray + _price + " " + ClansCurrency.GOLD.getPrefix() + " will be", C.cGray + "deducted from your account balance").build());
}
@ -33,7 +35,9 @@ public class GoldPurchaseProcessor implements ConfirmationProcessor {
int goldCount = _goldManager.Get(_player).getBalance();
if (_price > goldCount)
{
showResults(callback, TransactionResponse.InsufficientFunds);
}
else
{
_goldManager.rewardGold(data ->
@ -71,4 +75,4 @@ public class GoldPurchaseProcessor implements ConfirmationProcessor {
break;
}
}
}
}

View File

@ -1,14 +1,12 @@
package mineplex.game.clans.economy;
import mineplex.core.account.CoreClient;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import org.bukkit.entity.Player;
public class SetGoldCommand extends CommandBase<GoldManager>
{
@ -67,4 +65,4 @@ public class SetGoldCommand extends CommandBase<GoldManager>
}
}, caller.getName(), targetName, accountId, gold, true);
}
}
}

View File

@ -34,4 +34,4 @@ public class TransferTracker
GemTransfer transfer = _repository.getElement(player.getName());
return transfer != null && transfer.transferWasToday();
}
}
}

View File

@ -104,6 +104,9 @@ public class ClansHub extends JavaPlugin
ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager);
// Publish our server status now, to give us more time to start up
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
//Other Modules
PacketHandler packetHandler = require(PacketHandler.class);
DisguiseManager disguiseManager = require(DisguiseManager.class);
@ -120,7 +123,6 @@ public class ClansHub extends JavaPlugin
PollManager pollManager = new PollManager(this, clientManager, donationManager);
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
new TitanGiveawayManager(this, clientManager, serverStatusManager);
Portal portal = new Portal();

View File

@ -199,7 +199,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager);
_bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
_bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager, "Carter");
World world = _spawn.getWorld();
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());

View File

@ -122,6 +122,9 @@ public class Hub extends JavaPlugin implements IRelation
ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager);
// Publish our server status now, to give us more time to start up
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
//Other Modules
PacketHandler packetHandler = require(PacketHandler.class);
DisguiseManager disguiseManager = require(DisguiseManager.class);
@ -142,7 +145,6 @@ public class Hub extends JavaPlugin implements IRelation
ProjectileManager throwManager = new ProjectileManager(this);
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
new TitanGiveawayManager(this, clientManager, serverStatusManager);
Portal portal = new Portal();

View File

@ -227,7 +227,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager);
_bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
_bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager, "Carl");
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());
CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);

View File

@ -0,0 +1,3 @@
name: MineplexVotifier
main: mineplex.votifier.Votifier
version: 0.1

View File

@ -0,0 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-plugin</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../plugin.xml</relativePath>
</parent>
<name>MineplexVotifier</name>
<artifactId>mineplex-votifier</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>votifier</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,35 @@
package mineplex.votifier;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.command.CommandCenter;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.stats.StatsManager;
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);
DonationManager donationManager = Managers.require(DonationManager.class);
BonusManager bonusManager = new BonusManager(this, clientManager, donationManager);
InventoryManager inventoryManager = new InventoryManager(this, clientManager);
StatsManager statsManager = new StatsManager(this, clientManager);
VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager, inventoryManager, statsManager);
}
}

View File

@ -0,0 +1,409 @@
package mineplex.votifier;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import org.jooq.DSLContext;
import org.jooq.Record1;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
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.BonusManager;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Pair;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.treasure.TreasureType;
import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import mineplex.serverdata.Region;
import mineplex.serverdata.Utility;
import mineplex.serverdata.commands.ServerCommand;
import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.redis.RedisConfig;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ServerManager;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class VotifierManager extends MiniPlugin
{
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private BonusManager _bonusManager;
private InventoryManager _inventoryManager;
private StatsManager _statsManager;
private RedisConfig _usConfig;
private RedisConfig _euConfig;
private RedisDataRepository<PlayerStatus> _usPlayerRepo;
private RedisDataRepository<PlayerStatus> _euPlayerRepo;
private JedisPool _usWritePool;
private JedisPool _euWritePool;
private final boolean ClansVotifier;
public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager, InventoryManager inventoryManager, StatsManager statsManager)
{
super("Votifier", plugin);
_clientManager = clientManager;
_donationManager = donationManager;
_bonusManager = bonusManager;
_inventoryManager = inventoryManager;
_statsManager = statsManager;
_usConfig = ServerManager.loadConfig("us-redis.dat");
_euConfig = ServerManager.loadConfig("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"));
boolean found = false;
try
{
found = new File(new File(".").getCanonicalPath() + File.separator + "ClansVotifier.dat").exists();
}
catch (IOException e)
{
e.printStackTrace();
}
ClansVotifier = found;
}
@EventHandler
public void handleVote(VotifierEvent event)
{
final Vote vote = event.getVote();
final String playerName = vote.getUsername();
System.out.println("New Vote: " + playerName);
runAsync(new Runnable()
{
@Override
public void run()
{
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);
}
}
String lowerPlayerName = playerName.toLowerCase();
final PlayerStatus usStatus = _usPlayerRepo.getElement(lowerPlayerName);
final PlayerStatus euStatus = _euPlayerRepo.getElement(lowerPlayerName);
System.out.println("Loaded " + playerName + " with uuid " + uuid);
System.out.println("Attempting to award bonus");
final UUID finalUuid = uuid;
awardBonus(playerName, finalUuid, new Callback<Integer>()
{
@Override
public void run(final Integer reward)
{
runSync(new Runnable()
{
@Override
public void run()
{
if (usStatus != null)
{
System.out.println("Found " + playerName + " on US " + usStatus.getServer());
notifyServer(playerName, reward, Region.US, usStatus.getServer());
}
if (euStatus != null)
{
System.out.println("Found " + playerName + " on EU " + euStatus.getServer());
notifyServer(playerName, reward, Region.EU, euStatus.getServer());
}
}
});
}
});
}
});
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, true);
}
private void notifyServer(String playerName, int reward, Region region, String targetServer)
{
JedisPool writePool = region == Region.EU ? _euWritePool : _usWritePool;
VotifierCommand command = new VotifierCommand(playerName, reward, ClansVotifier, targetServer);
publishCommand(command, writePool);
}
private void awardBonus(final String playerName, final UUID uuid, final Callback<Integer> onComplete)
{
DSLContext create = DSL.using(DBPool.getAccount(), 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 BonusRecord client = _bonusManager.getRepository().loadRecord(playerName, accountId);
final int homeServerId = _bonusManager.getRepository().loadClansServerId(accountId);
if (homeServerId == -1 && ClansVotifier)
{
return;
}
final BonusAmount amount = ClansVotifier ? _bonusManager.getClansVoteBonusAmount(homeServerId) : _bonusManager.getVoteBonusAmount(client.getVoteStreak());
_bonusManager.getRepository().attemptVoteBonus(accountId, ClansVotifier, new Callback<Pair<Boolean, Date>>()
{
@Override
public void run(Pair<Boolean, Date> pair)
{
if (pair.getLeft())
{
// Reward Amount
final int gems = amount.getTotalGems();
final int gold = amount.getTotalGold();
final int shards = amount.getTotalShards();
final int tickets = amount.getTickets();
int experience = amount.getTotalExperience();
int oldChests = amount.getOldChests();
int ancientChests = amount.getAncientChests();
int mythicalChests = amount.getMythicalChests();
int illuminatedChests = amount.getIlluminatedChests();
int omegaChests = amount.getOmegaChests();
if (oldChests > 0)
{
_inventoryManager.addItemToInventoryForOffline(data ->
{
if (data)
{
System.out.println("Gave " + oldChests + " old chest(s) to " + playerName);
}
else
{
System.out.println("Failed to give " + oldChests + " old chest(s) to " + playerName);
}
}, accountId, TreasureType.OLD.getItemName(), oldChests);
}
if (ancientChests > 0)
{
_inventoryManager.addItemToInventoryForOffline(data ->
{
if (data)
{
System.out.println("Gave " + ancientChests + " ancient chest(s) to " + playerName);
}
else
{
System.out.println("Failed to give " + ancientChests + " ancient chest(s) to " + playerName);
}
}, accountId, TreasureType.ANCIENT.getItemName(), ancientChests);
}
if (mythicalChests > 0)
{
_inventoryManager.addItemToInventoryForOffline(data ->
{
if (data)
{
System.out.println("Gave " + mythicalChests + " mythical chest(s) to " + playerName);
}
else
{
System.out.println("Failed to give " + mythicalChests + " mythical chest(s) to " + playerName);
}
}, accountId, TreasureType.MYTHICAL.getItemName(), mythicalChests);
}
if (illuminatedChests > 0)
{
_inventoryManager.addItemToInventoryForOffline(data ->
{
if (data)
{
System.out.println("Gave " + illuminatedChests + " illuminated chest(s) to " + playerName);
}
else
{
System.out.println("Failed to give " + illuminatedChests + " illuminated chest(s) to " + playerName);
}
}, accountId, TreasureType.ILLUMINATED.getItemName(), illuminatedChests);
}
if (omegaChests > 0)
{
_inventoryManager.addItemToInventoryForOffline(data ->
{
if (data)
{
System.out.println("Gave " + omegaChests + " omega chest(s) to " + playerName);
}
else
{
System.out.println("Failed to give " + omegaChests + " omega chest(s) to " + playerName);
}
}, accountId, TreasureType.OMEGA.getItemName(), omegaChests);
}
if (gems > 0)
{
_donationManager.rewardCurrency(GlobalCurrency.GEM, playerName, uuid, "Votifier", gems, data ->
{
if (data)
{
System.out.println("Gave " + gems + " gems to " + playerName);
}
else
{
System.out.println("Failed to give " + gems + " gems to " + playerName);
}
});
}
if (gold > 0)
{
Set<Integer> serverIds = new HashSet<>();
serverIds.addAll(amount.getGold().getServerIds());
serverIds.addAll(amount.getBonusGold().getServerIds());
for (Integer serverId : serverIds)
{
int goldCount = amount.getGold().getGoldFor(serverId) + amount.getBonusGold().getGoldFor(serverId);
_donationManager.getGoldRepository().rewardGold(data ->
{
if (data)
{
System.out.println("Gave " + goldCount + " gold to " + playerName + " on clans server id " + serverId);
}
else
{
System.out.println("Failed to give " + goldCount + " gold to " + playerName + " on clans server id " + serverId);
}
}, serverId, accountId, goldCount);
}
}
if (shards > 0)
{
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, playerName, uuid, "Votifier", shards, data ->
{
if (data)
{
System.out.println("Gave " + shards + " shards to " + playerName);
}
else
{
System.out.println("Failed to give " + shards + " shards to " + playerName);
}
});
}
if (experience > 0)
{
_statsManager.incrementStat(accountId, "Global.ExpEarned", experience);
System.out.println("Gave " + experience + " experience to " + playerName);
}
if (tickets > 0)
{
client.setTickets(client.getTickets() + tickets);
}
// Check if we need to reset vote streak
_bonusManager.updateVoteStreak(client);
client.setVotetime(pair.getRight());
// Update Streak
_bonusManager.incrementVoteStreak(client);
client.store();
System.out.println("Awarded " + tickets + " carl ticket(s) to " + playerName);
onComplete.run(ClansVotifier ? amount.getTotalGold() : amount.getTotalGems());
}
else
{
System.out.println(playerName + " attempted to vote, vote bonus returned false!");
}
}
});
}
}
private void publishCommand(final ServerCommand serverCommand, final JedisPool writePool)
{
new Thread(new Runnable()
{
public void run()
{
try (Jedis jedis = writePool.getResource())
{
String commandType = serverCommand.getClass().getSimpleName();
String serializedCommand = Utility.serialize(serverCommand);
jedis.publish("commands.server" + ":" + commandType, serializedCommand);
}
}
}).start();
}
}

View File

@ -118,7 +118,10 @@ public class Arcade extends JavaPlugin
Recharge.Initialize(this);
VisibilityManager.Initialize(this);
Give.Initialize(this);
// Publish our server status now, to give us more time to start up
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
//Velocity Fix
new VelocityFix(this);
@ -134,7 +137,6 @@ public class Arcade extends JavaPlugin
incognito.setPreferencesManager(preferenceManager);
Creature creature = new Creature(this);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager);
Teleport teleport = new Teleport(this, _clientManager);
Portal portal = new Portal();

View File

@ -125,7 +125,6 @@ import mineplex.minecraft.game.core.fire.Fire;
import mineplex.serverdata.Region;
import nautilus.game.arcade.addons.SoupAddon;
import nautilus.game.arcade.addons.TeamArmorAddon;
import nautilus.game.arcade.booster.GameBoosterManager;
import nautilus.game.arcade.command.CancelNextGameCommand;
import nautilus.game.arcade.command.GameCmdModeCommand;
@ -343,7 +342,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager);
_bonusManager = new BonusManager(plugin, _gameLobbyManager.getCarl(), playWireManager, clientManager, donationManager, pollManager, npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager);
_bonusManager = new BonusManager(plugin, _gameLobbyManager.getCarl(), playWireManager, clientManager, donationManager, pollManager, npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager, "Carl");
new GameLootManager(this, petManager, _bonusManager.getRewardManager());
_spectatorManager = new GameSpectatorManager(this);
@ -365,7 +364,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Game Addons
new SoupAddon(plugin, this);
new TeamArmorAddon(plugin, this);
//Champions Modules
_energy = new Energy(plugin);

View File

@ -1,99 +0,0 @@
package nautilus.game.arcade.addons;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilGear;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
public class TeamArmorAddon extends MiniPlugin
{
public ArcadeManager Manager;
public TeamArmorAddon(JavaPlugin plugin, ArcadeManager manager)
{
super("Team Armor Addon", plugin);
Manager = manager;
}
@EventHandler
public void GiveArmor(PlayerKitGiveEvent event)
{
Player player = event.getPlayer();
if (event.getGame().TeamArmor)
{
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();
metaHelm.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
helm.setItemMeta(metaHelm);
player.getInventory().setHelmet(helm);
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
armor.setItemMeta(meta);
player.getInventory().setChestplate(armor);
ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta metaLegs = (LeatherArmorMeta)legs.getItemMeta();
metaLegs.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
legs.setItemMeta(metaLegs);
player.getInventory().setLeggings(legs);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta metaBoots = (LeatherArmorMeta)boots.getItemMeta();
metaBoots.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
boots.setItemMeta(metaBoots);
player.getInventory().setBoots(boots);
}
if (event.getGame().TeamArmorHotbar && event.getGame().InProgress())
{
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
meta.setDisplayName(Manager.GetGame().GetTeam(player).GetFormattedName());
armor.setItemMeta(meta);
player.getInventory().setItem(8, armor.clone());
}
}
@EventHandler
public void EquipCancel(PlayerInteractEvent event)
{
if (Manager.GetGame() == null)
return;
if (!Manager.GetGame().TeamArmorHotbar)
return;
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.LEATHER_CHESTPLATE))
event.setCancelled(true);
}
@EventHandler
public void ClickCancel(InventoryClickEvent event)
{
if (Manager.GetGame() == null)
return;
if (!Manager.GetGame().TeamArmorHotbar)
return;
if (!Manager.GetGame().InProgress())
return;
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
}

View File

@ -286,8 +286,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
// Addons
public boolean SoupEnabled = true;
public boolean TeamArmor = false;
public boolean TeamArmorHotbar = false;
public boolean GiveClock = true;
@ -296,7 +294,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
public long PrepareTime = 9000;
public boolean PlaySoundGameStart = true;
public double XpMult = 1;
public double XpMult = 2;
public boolean SpeedMeasurement = false;

View File

@ -26,6 +26,7 @@ import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.basketball.data.ScoringManager;
import nautilus.game.arcade.game.games.basketball.data.ThrowData;
import nautilus.game.arcade.game.games.basketball.kit.BasketballPlayerKit;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_8_R3.BlockPosition;
@ -93,9 +94,7 @@ public class Basketball extends TeamGame
"Left Click an opposing player to try and steal the ball"
}
);
this.TeamArmor = true;
this.TeamArmorHotbar = true;
this.HealthSet = 20;
this.HungerSet = 20;
this.Damage = false;
@ -109,6 +108,11 @@ public class Basketball extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
private boolean isOutOfBounds(Location loc, boolean ball)

View File

@ -40,6 +40,7 @@ import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.dragonescape.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -79,8 +80,6 @@ public class DragonEscapeTeams extends TeamGame
this.DamagePvP = false;
this.HungerSet = 20;
this.TeamArmorHotbar = true;
registerChatStats(
Deaths,
@ -88,6 +87,9 @@ public class DragonEscapeTeams extends TeamGame
BlankLine,
new ChatStatData("kit", "Kit", true)
);
new TeamArmorModule()
.giveHotbarItem()
.register(this);
}
@Override

View File

@ -29,6 +29,7 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.dragons.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkSparkler;
@ -67,9 +68,6 @@ public class DragonsTeams extends TeamGame
this.HungerSet = 20;
this.WorldWaterDamage = 4;
this.PrepareFreeze = false;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
registerChatStats(
Deaths,
@ -77,6 +75,11 @@ public class DragonsTeams extends TeamGame
BlankLine,
new ChatStatData("kit", "Kit", true)
);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@Override

View File

@ -43,8 +43,7 @@ public class ChampionsGladiators extends Gladiators
Manager.getClassManager().GetItemFactory().getProximityManager().setProxyLimit(6);
StrictAntiHack = true;
TeamArmor = false;
StrictAntiHack = true;
new ChampionsFixes(this);

View File

@ -41,6 +41,7 @@ import nautilus.game.arcade.game.games.lobbers.trackers.TrackerBlastProof;
import nautilus.game.arcade.game.games.lobbers.trackers.TrackerDirectHit;
import nautilus.game.arcade.game.games.lobbers.trackers.TrackerNoDamage;
import nautilus.game.arcade.game.games.lobbers.trackers.TrackerTNTThrown;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -100,9 +101,6 @@ public class BombLobbers extends TeamGame implements IThrown
PrepareFreeze = false;
TeamArmor = true;
TeamArmorHotbar = true;
InventoryOpenChest = false;
InventoryOpenBlock = false;
@ -137,6 +135,11 @@ public class BombLobbers extends TeamGame implements IThrown
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@EventHandler

View File

@ -21,6 +21,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.micro.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -54,9 +55,6 @@ public class Micro extends TeamGame
this.StrictAntiHack = true;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
this.InventoryClick = true;
this.ItemDrop = true;
@ -70,6 +68,11 @@ public class Micro extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
public Micro(ArcadeManager manager)

View File

@ -24,8 +24,6 @@ public class OverpoweredMicroBattles extends Micro
},
GameType.Brawl);
TeamArmor = false;
new AbsorptionFix(this);
}

View File

@ -41,7 +41,6 @@ public class TinyWinners extends Micro
Manager.getClassManager().GetItemFactory().getProximityManager().setProxyLimit(6);
StrictAntiHack = true;
TeamArmor = false;
manager.enableChampionsModules();
}

View File

@ -27,6 +27,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.monsterleague.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
@ -61,9 +62,6 @@ public class MonsterLeague extends TeamGame
this.HealthSet = 20;
this.DeathOut = false;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
registerChatStats();
@ -72,6 +70,11 @@ public class MonsterLeague extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
//Supports anywhere from 2-4 teams on a map

View File

@ -74,6 +74,7 @@ import nautilus.game.arcade.game.games.paintball.kits.KitSniper;
import nautilus.game.arcade.game.games.paintball.trackers.KillingSpreeTracker;
import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker;
import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.WinFastStatTracker;
@ -106,8 +107,6 @@ public class Paintball extends TeamGame
HungerSet = 20;
InventoryClick = false;
TeamArmorHotbar = true;
registerStatTrackers(
new KillingSpreeTracker(this),
@ -132,6 +131,9 @@ public class Paintball extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveHotbarItem()
.register(this);
}
@EventHandler
@ -507,6 +509,9 @@ public class Paintball extends TeamGame
//Clean Armor
CleanColorArmor(player);
//Reapply Team Item
getModule(TeamArmorModule.class).apply(player);
//Inform
UtilPlayer.message(player, F.main("Game", "You have been cleaned!"));

View File

@ -30,6 +30,7 @@ import nautilus.game.arcade.game.games.quiver.module.ModuleSuperArrow;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.module.QuiverTeamModule;
import nautilus.game.arcade.game.games.quiver.module.game.QuiverPayload;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.VersionModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
@ -63,8 +64,6 @@ public class QuiverTeamBase extends TeamGame
this.DamageSelf = false;
this.DamageTeamSelf = false;
this.DamageFall = false;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
this.HungerSet = 20;
registerStatTrackers(new WinWithoutBowStatTracker(this, "Bow"));
@ -102,6 +101,11 @@ public class QuiverTeamBase extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@Override

View File

@ -27,6 +27,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.quiver.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
@ -63,9 +64,6 @@ public class QuiverTeams extends TeamGame
this.BlockBreakAllow.add(102);
this.BlockBreakAllow.add(20);
this.BlockBreakAllow.add(18);
this.TeamArmor = true;
this.TeamArmorHotbar = true;
registerChatStats(
Kills,
@ -82,6 +80,10 @@ public class QuiverTeams extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@EventHandler(priority = EventPriority.HIGH)

View File

@ -56,6 +56,7 @@ import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.sheep.kits.KitArcher;
import nautilus.game.arcade.game.games.sheep.kits.KitBeserker;
import nautilus.game.arcade.game.games.sheep.kits.KitBrute;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -181,14 +182,15 @@ public class SheepGame extends TeamGame
this.WorldTimeSet = 2000;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@Override

View File

@ -46,8 +46,7 @@ public class EweHeroes extends SheepGame
Manager.getClassManager().GetItemFactory().getProximityManager().setProxyLimit(6);
StrictAntiHack = true;
TeamArmor = false;
StrictAntiHack = true;
new ChampionsFixes(this);

View File

@ -22,8 +22,6 @@ public class OverpoweredSheepQuest extends SheepGame
new KitShepherd(manager)
}, GameType.Brawl);
TeamArmor = false;
new AbsorptionFix(this);
}

View File

@ -19,6 +19,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.FreeKitWinStatTracker;
@ -40,8 +41,6 @@ public class TeamSuperSmash extends SuperSmash
SpawnNearAllies = true;
DamageTeamSelf = false;
TeamArmorHotbar = true;
DontAllowOverfill = true;
TeamMode = true;
@ -52,6 +51,10 @@ public class TeamSuperSmash extends SuperSmash
new RecoveryMasterStatTracker(this));
registerChatStats(Kills, Deaths, KDRatio, BlankLine, Assists, DamageTaken, DamageDealt, BlankLine, new ChatStatData("kit", "Kit", true));
new TeamArmorModule()
.giveHotbarItem()
.register(this);
}
@Override

View File

@ -30,6 +30,7 @@ import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.snowfight.kits.KitTactician;
import nautilus.game.arcade.game.games.snowfight.kits.KitMedic;
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
@ -90,9 +91,6 @@ public class SnowFight extends TeamGame
.setGiveCompassToAlive(true)
.setGiveCompass(false)
.register(this);
this.TeamArmor = true;
this.TeamArmorHotbar = true;
registerChatStats(//damage, collected
Kills,
@ -101,6 +99,10 @@ public class SnowFight extends TeamGame
DamageTaken,
DamageDealt
);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
// this.WorldWeatherEnabled = true;
// this.WorldTimeSet = 4000;

View File

@ -29,6 +29,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.spleef.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -57,9 +58,6 @@ public class SpleefTeams extends TeamGame
this.WorldWaterDamage = 4;
this.PrepareFreeze = false;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
registerChatStats(
Kills,
@ -69,6 +67,10 @@ public class SpleefTeams extends TeamGame
BlankLine,
new ChatStatData("kit", "Kit", true)
);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@EventHandler

View File

@ -37,6 +37,7 @@ import nautilus.game.arcade.game.games.typewars.stats.PerfectionistStatTracker;
import nautilus.game.arcade.game.games.typewars.stats.TimeInGameTracker;
import nautilus.game.arcade.game.games.typewars.stats.WaitForItStatTracker;
import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent;
import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent;
@ -123,13 +124,10 @@ public class TypeWars extends TeamGame
this.HungerSet = 20;
this.WorldBoundaryKill = true;
this.TeamArmor = true;
this.TeamArmorHotbar = false;
this.WorldTimeSet = 6000;
this.DamageEvP = false;
this.DamagePvE = false;
this.DamagePvP = false;
this.TeamArmorHotbar = true;
this.Damage = false;
this.CreatureAllow = false;
this.PrepareTime = 50000;
@ -180,6 +178,11 @@ public class TypeWars extends TeamGame
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@EventHandler

View File

@ -64,6 +64,7 @@ import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher;
import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor;
import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic;
import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
@ -130,9 +131,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
this.ItemPickup = true;
this.KitRegisterState = GameState.Prepare;
this.TeamArmor = true;
this.TeamArmorHotbar = false;
this.InventoryClick = false;
this.InventoryOpenBlock = false;
@ -164,6 +162,9 @@ public class WitherGame extends TeamGame implements IBlockRestorer
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.register(this);
}
@Override

View File

@ -0,0 +1,139 @@
package nautilus.game.arcade.game.modules;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
/**
* This module handles setting armor for team games such as Micro Battles. It allows you to set the player's armor
* to be the team's color. It also allows you to add an chestplate to players' hotbar representing their team.
*
* These events are listening at MONITOR because they (should) be strict enough that it should not be possible to
* interfere with any other listeners
*/
public class TeamArmorModule extends Module
{
private boolean _giveTeamArmor = false;
private boolean _giveHotbarItem = false;
private Set<String> _hotbarNames = new HashSet<>();
private Set<String> _armorNames = new HashSet<>();
public TeamArmorModule giveTeamArmor()
{
this._giveTeamArmor = true;
return this;
}
public TeamArmorModule giveHotbarItem()
{
this._giveHotbarItem = true;
return this;
}
@EventHandler
public void giveArmor(PlayerKitGiveEvent event)
{
apply(event.getPlayer());
}
public void apply(Player player)
{
Color color = getGame().GetTeam(player).GetColorBase();
if (_giveTeamArmor)
{
String itemName = getGame().GetTeam(player).GetColor() + C.Bold + "Team Armor";
_armorNames.add(itemName);
player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(color).setTitle(itemName).setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(color).setTitle(itemName).setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(color).setTitle(itemName).setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(color).setTitle(itemName).setUnbreakable(true).build());
}
if (_giveHotbarItem && getGame().InProgress())
{
String teamName = getGame().GetTeam(player).GetFormattedName();
_hotbarNames.add(teamName);
player.getInventory().setItem(8, new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(color).setTitle(teamName).setUnbreakable(true).build());
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void disallowDrop(PlayerDropItemEvent event)
{
if (!_giveTeamArmor && !_giveHotbarItem)
return;
if (!_hotbarNames.contains(UtilItem.getDisplayName(event.getItemDrop().getItemStack())))
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void disallowEquip(PlayerInteractEvent event)
{
if (!_giveHotbarItem)
return;
if (!UtilEvent.isAction(event, UtilEvent.ActionType.R))
return;
if (!_hotbarNames.contains(UtilItem.getDisplayName(event.getItem())))
return;
event.setCancelled(true);
getGame().getArcadeManager().runSyncLater(() ->
{
event.getPlayer().updateInventory();
}, 1L);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void disallowMoveHotbar(InventoryClickEvent event)
{
if (!_giveHotbarItem)
return;
if (!getGame().InProgress())
return;
if (!UtilInv.shouldCancelEvent(event, item -> _hotbarNames.contains(UtilItem.getDisplayName(item))))
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void disallowMoveArmor(InventoryClickEvent event)
{
if (!_giveTeamArmor)
return;
if (!getGame().InProgress())
return;
if (!UtilInv.shouldCancelEvent(event, item -> _armorNames.contains(UtilItem.getDisplayName(item))))
return;
event.setCancelled(true);
}
}

View File

@ -58,10 +58,20 @@ public class MiscManager implements Listener
event.getPlayer().getItemInHand().getData().getData() == (byte)15)
{
event.setCancelled(true);
Manager.runSyncLater(() ->
{
event.getPlayer().updateInventory();
}, 1L);
}
else if (Manager.GetGame().GetState() != GameState.Live)
{
event.setCancelled(true);
Manager.runSyncLater(() ->
{
event.getPlayer().updateInventory();
}, 1L);
}
}

View File

@ -133,7 +133,7 @@ public class Hub extends JavaPlugin
preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito);
ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager);
BoosterManager boosterManager = new BoosterManager(this, serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager);
RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, gadgetManager);
RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, gadgetManager, statsManager);
TreasureManager treasureManager = new TreasureManager(this, _clientManager, serverStatusManager, _donationManager, inventoryManager, petManager, gadgetManager, blockRestore, hologramManager, statsManager, rewardManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager,
mountManager, petManager, treasureManager, boosterManager);

View File

@ -14,7 +14,6 @@ import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.beta.BetaWhitelist;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.chat.Chat;
@ -48,7 +47,6 @@ import mineplex.core.party.PartyManager;
import mineplex.core.pet.PetManager;
import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Portal;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
@ -299,9 +297,6 @@ public class GemHunters extends JavaPlugin
// Two-factor auth
require(TwoFactorAuth.class);
// beta whitelist
new BetaWhitelist(clientManager, new PowerPlayClubRepository(this, clientManager, donationManager));
}
@Override

View File

@ -36,6 +36,7 @@
<module>Mineplex.ServerData</module>
<module>Mineplex.ServerMonitor</module>
<module>Mineplex.StaffServer</module>
<module>Mineplex.Votifier</module>
<module>Nautilus.Game.Arcade</module>
<module>Nautilus.Game.Arcade.UHC.WorldGen</module>
@ -65,6 +66,12 @@
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>votifier</artifactId>
<version>1.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>