Merge branch 'Bonus' of ssh://184.154.0.242:7999/min/mineplex into Bonus
This commit is contained in:
commit
97c6726d1d
@ -137,15 +137,6 @@ public class AchievementManager extends MiniPlugin
|
||||
_log.remove(event.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_giveInterfaceItem)
|
||||
{
|
||||
giveInterfaceItem(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public void clearLog(Player player)
|
||||
{
|
||||
_log.remove(player.getName());
|
||||
@ -161,22 +152,7 @@ public class AchievementManager extends MiniPlugin
|
||||
_giveInterfaceItem = giveInterfaceItem;
|
||||
}
|
||||
|
||||
public void giveInterfaceItem(Player player)
|
||||
{
|
||||
if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.SKULL_ITEM))
|
||||
{
|
||||
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats");
|
||||
SkullMeta meta = ((SkullMeta) item.getItemMeta());
|
||||
meta.setOwner(player.getName());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
player.getInventory().setItem(_interfaceSlot, item);
|
||||
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/*@EventHandler
|
||||
public void openShop(PlayerInteractEvent event)
|
||||
{
|
||||
if (!_shopEnabled)
|
||||
@ -188,7 +164,7 @@ public class AchievementManager extends MiniPlugin
|
||||
|
||||
openShop(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean hasCategory(Player player, Achievement[] required)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ public class HostServerCommand extends CommandBase<PersonalServerManager>
|
||||
{
|
||||
public HostServerCommand(PersonalServerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.LEGEND, "hostserver");
|
||||
super(plugin, Rank.LEGEND, "hostserver", "mps");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,6 @@ public class PersonalServerManager extends MiniPlugin
|
||||
{
|
||||
if (_giveInterfaceItem)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,19 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.preferences.command.PreferencesCommand;
|
||||
import mineplex.core.preferences.ui.PreferencesShop;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,18 +24,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.preferences.command.PreferencesCommand;
|
||||
import mineplex.core.preferences.ui.PreferencesShop;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
{
|
||||
private PreferencesRepository _repository;
|
||||
@ -53,6 +58,27 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void givePlayerItem(PlayerJoinEvent event)
|
||||
{
|
||||
if (!GiveItem)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM))
|
||||
{
|
||||
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "My Profile");
|
||||
SkullMeta meta = ((SkullMeta) item.getItemMeta());
|
||||
meta.setOwner(player.getName());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
player.getInventory().setItem(8, item);
|
||||
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void storeBuffer(UpdateEvent event)
|
||||
{
|
||||
@ -76,15 +102,6 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void givePlayerItem(PlayerJoinEvent event)
|
||||
{
|
||||
if (!GiveItem)
|
||||
return;
|
||||
|
||||
event.getPlayer().getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs"));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
|
@ -16,6 +16,8 @@ public abstract class Animation
|
||||
_treasure = treasure;
|
||||
_running = true;
|
||||
}
|
||||
|
||||
public Animation() {}
|
||||
|
||||
public void run()
|
||||
{
|
||||
@ -50,5 +52,15 @@ public abstract class Animation
|
||||
{
|
||||
return _treasure;
|
||||
}
|
||||
|
||||
public void setRunning(boolean b)
|
||||
{
|
||||
_running = b;
|
||||
}
|
||||
|
||||
public void setTicks(int ticks)
|
||||
{
|
||||
_ticks = ticks;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package mineplex.core.votifier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class RedisVotifierCommand extends ServerCommand
|
||||
{
|
||||
private UUID _voterUUID;
|
||||
|
||||
|
||||
public RedisVotifierCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.votifier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class VotifierCommand extends ServerCommand
|
||||
{
|
||||
private String _playerName;
|
||||
|
||||
public VotifierCommand(String playerName, String targetServer)
|
||||
{
|
||||
super(targetServer);
|
||||
|
||||
_playerName = playerName;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
}
|
@ -122,7 +122,9 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
|
||||
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager);
|
||||
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
|
||||
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager);
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
|
||||
|
||||
@ -141,7 +143,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
}
|
||||
});
|
||||
//new Replay(this, packetHandler);
|
||||
new PersonalServerManager(this, clientManager);
|
||||
|
||||
|
||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||
|
||||
|
@ -25,6 +25,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -74,6 +75,7 @@ import mineplex.core.notifier.NotificationManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.personalServer.PersonalServerManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
@ -97,6 +99,7 @@ import mineplex.hub.modules.ParkourManager;
|
||||
import mineplex.hub.modules.TextManager;
|
||||
import mineplex.hub.modules.WorldManager;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.hub.profile.gui.GUIProfile;
|
||||
import mineplex.hub.tutorial.TutorialManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
||||
@ -115,6 +118,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private DisguiseManager _disguiseManager;
|
||||
private PartyManager _partyManager;
|
||||
private ForcefieldManager _forcefieldManager;
|
||||
private PollManager _pollManager;
|
||||
private Portal _portal;
|
||||
private StatsManager _statsManager;
|
||||
private GadgetManager _gadgetManager;
|
||||
@ -129,6 +133,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private AchievementManager _achievementManager;
|
||||
private TreasureManager _treasureManager;
|
||||
private PetManager _petManager;
|
||||
private PersonalServerManager _personalServerManager;
|
||||
|
||||
private Location _spawn;
|
||||
private int _scoreboardTick = 0;
|
||||
@ -149,7 +154,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
//Admin
|
||||
private boolean _gadgetsEnabled = true;
|
||||
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager)
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager)
|
||||
{
|
||||
super("Hub Manager", plugin);
|
||||
|
||||
@ -158,6 +163,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_conditionManager = conditionManager;
|
||||
_donationManager = donationManager;
|
||||
_disguiseManager = disguiseManager;
|
||||
_pollManager = pollManager;
|
||||
_personalServerManager = personalServerManager;
|
||||
|
||||
_portal = portal;
|
||||
|
||||
@ -207,7 +214,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
||||
|
||||
|
||||
new BonusManager(plugin, clientManager, donationManager, npcManager, hologramManager, rewardManager);
|
||||
new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, rewardManager);
|
||||
|
||||
|
||||
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
|
||||
@ -1092,4 +1099,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false)));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void openProfile(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.getItem().getType() != Material.SKULL_ITEM)
|
||||
return;
|
||||
|
||||
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();;
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,6 @@ public class BonusAmount
|
||||
addLore(lore, getGems(), getBonusGems(), "Gems");
|
||||
addLore(lore, getGold(), getBonusGold(), "Gold");
|
||||
addLore(lore, getExperience(), getBonusExperience(), "Experience");
|
||||
lore.add(" ");
|
||||
}
|
||||
|
||||
private void addLore(List<String> lore, int amount, int bonus, String suffix)
|
||||
|
@ -2,9 +2,10 @@ package mineplex.hub.bonuses;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.TimeZone;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
@ -15,7 +16,16 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.disguise.disguises.DisguiseCreeper;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
@ -24,19 +34,33 @@ import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.votifier.VotifierCommand;
|
||||
import mineplex.hub.bonuses.animations.AnimationCarl;
|
||||
import mineplex.hub.bonuses.commands.AnimationCommand;
|
||||
import mineplex.hub.bonuses.commands.GuiCommand;
|
||||
import mineplex.hub.bonuses.event.CarlSpinnerEvent;
|
||||
import mineplex.hub.bonuses.gui.BonusGui;
|
||||
import mineplex.database.tables.records.BonusRecord;
|
||||
import mineplex.hub.bonuses.gui.SpinGui;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||
|
||||
@ -46,6 +70,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
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 long _explode;
|
||||
private boolean _canVote;
|
||||
|
||||
public static long getSqlTime()
|
||||
{
|
||||
@ -83,12 +112,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private BonusRepository _repository;
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private PollManager _pollManager;
|
||||
private NpcManager _npcManager;
|
||||
private HologramManager _hologramManager;
|
||||
private RewardManager _rewardManager;
|
||||
private Npc _carlNpc;
|
||||
private AnimationCarl _animation;
|
||||
|
||||
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, NpcManager npcManager, HologramManager hologramManager, RewardManager rewardManager)
|
||||
// Streak
|
||||
private StreakRecord _dailyStreak;
|
||||
private StreakRecord _voteStreak;
|
||||
|
||||
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, RewardManager rewardManager)
|
||||
{
|
||||
super("Bonus", plugin);
|
||||
_repository = new BonusRepository(plugin, this, donationManager);
|
||||
@ -97,19 +132,28 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_npcManager = npcManager;
|
||||
_hologramManager = hologramManager;
|
||||
_rewardManager = rewardManager;
|
||||
_pollManager = pollManager;
|
||||
|
||||
// Hope to god this works!
|
||||
_canVote = true;
|
||||
_carlNpc = _npcManager.getNpcByName("Carl the Creeper");
|
||||
_animation = new AnimationCarl(_carlNpc.getEntity());
|
||||
_animation.setRunning(false);
|
||||
|
||||
clientManager.addStoredProcedureLoginProcessor(this);
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class,
|
||||
new VoteHandler(this));
|
||||
|
||||
updateOffSet();
|
||||
updateStreakRecord();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new GuiCommand(this));
|
||||
addCommand(new AnimationCommand(this));
|
||||
}
|
||||
|
||||
// Just keeping things up-to-date
|
||||
@ -122,28 +166,162 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
updateOffSet();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateStreak(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_16)
|
||||
return;
|
||||
|
||||
updateStreakRecord();
|
||||
}
|
||||
|
||||
private void updateStreakRecord()
|
||||
{
|
||||
_repository.getDailyStreakRecord(new Callback<StreakRecord>()
|
||||
{
|
||||
@Override
|
||||
public void run(StreakRecord data)
|
||||
{
|
||||
_dailyStreak = data;
|
||||
}
|
||||
});
|
||||
|
||||
_repository.getVoteStreakRecord(new Callback<StreakRecord>()
|
||||
{
|
||||
@Override
|
||||
public void run(StreakRecord data)
|
||||
{
|
||||
_voteStreak = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public StreakRecord getDailyStreak()
|
||||
{
|
||||
return _dailyStreak;
|
||||
}
|
||||
|
||||
public StreakRecord getVoteStreak()
|
||||
{
|
||||
return _voteStreak;
|
||||
}
|
||||
|
||||
public void handleVote(Player player)
|
||||
{
|
||||
addPendingExplosion(player, player.getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fireCreeper(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
if(_pendingExplosions.isEmpty())
|
||||
return;
|
||||
|
||||
if(!_canVote)
|
||||
return;
|
||||
|
||||
if(_pendingExplosions.get(0) instanceof String)
|
||||
{
|
||||
String name = (String)_pendingExplosions.get(0);
|
||||
Bukkit.broadcastMessage("Recieved Vote: " + name);
|
||||
}
|
||||
_explode = System.currentTimeMillis();
|
||||
_animation.setTicks(0);
|
||||
_canVote = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void creeperAnimation(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if(_canVote)
|
||||
return;
|
||||
|
||||
Entity creeper = _carlNpc.getEntity();
|
||||
|
||||
double elapsed = (System.currentTimeMillis() - _explode)/1000d;
|
||||
|
||||
//Not Detonated
|
||||
if (elapsed < 1)
|
||||
{
|
||||
//Sound
|
||||
creeper.getWorld().playSound(creeper.getLocation(), Sound.CREEPER_HISS, (float)(0.5 + elapsed), (float)(0.5 + elapsed));
|
||||
|
||||
IncreaseSize(creeper);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!_animation.isRunning())
|
||||
{
|
||||
//Effect
|
||||
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
|
||||
creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f);
|
||||
_animation.setType(_pendingExplosions.get(0));
|
||||
_animation.setPlayer(_pendingExplosionsPlayers.get(0));
|
||||
_animation.setTime(System.currentTimeMillis());
|
||||
_animation.setRunning(true);
|
||||
}
|
||||
|
||||
if(!_animation.isDone())
|
||||
return;
|
||||
|
||||
DecreaseSize(creeper);
|
||||
_pendingExplosions.remove(0);
|
||||
_pendingExplosionsPlayers.remove(0);
|
||||
_canVote = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateAnimation(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if(!_animation.isRunning())
|
||||
return;
|
||||
|
||||
_animation.run();
|
||||
}
|
||||
|
||||
public void DecreaseSize(Entity player)
|
||||
{
|
||||
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, -1);
|
||||
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(17, 1);
|
||||
}
|
||||
|
||||
public void IncreaseSize(Entity player)
|
||||
{
|
||||
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, 1);
|
||||
}
|
||||
|
||||
// DAILY BONUS
|
||||
|
||||
public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20;
|
||||
public static final long STREAK_RESET_TIME = 1000 * 60 * 60 * 12;
|
||||
|
||||
public void attemptDailyBonus(final Player player, final BonusAmount amount, final Consumer<Boolean> result)
|
||||
public void attemptDailyBonus(final Player player, final BonusAmount amount, final Callback<Boolean> result)
|
||||
{
|
||||
if (timeTillDailyBonus(player) > 0)
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
|
||||
getRepository().attemptDailyBonus(player, new Consumer<Boolean>()
|
||||
getRepository().attemptDailyBonus(player, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Boolean r)
|
||||
public void run(Boolean r)
|
||||
{
|
||||
if (r)
|
||||
{
|
||||
incrementDailyStreak(player);
|
||||
awardBonus(player, amount);
|
||||
updateCreeperVisual(player);
|
||||
}
|
||||
|
||||
result.accept(r);
|
||||
result.run(r);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -167,22 +345,67 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
|
||||
// RANK BONUS
|
||||
public void attemptRankBonus(final Player player, final Consumer<Boolean> result)
|
||||
public void attemptRankBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (timeTillRankBonus(player) > 0)
|
||||
result.accept(false);
|
||||
getRepository().attemptRankBonus(player, new Consumer<Boolean>()
|
||||
result.run(false);
|
||||
getRepository().attemptRankBonus(player, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Boolean aBoolean)
|
||||
public void run(Boolean aBoolean)
|
||||
{
|
||||
if (aBoolean)
|
||||
{
|
||||
awardBonus(player, getRankBonusAmount(player));
|
||||
updateCreeperVisual(player);
|
||||
}
|
||||
|
||||
result.accept(aBoolean);
|
||||
result.run(aBoolean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptCarlSpin(final Player player)
|
||||
{
|
||||
final BonusClientData clientData = Get(player);
|
||||
|
||||
if (clientData.getTickets() > 0)
|
||||
{
|
||||
CarlSpinnerEvent event = new CarlSpinnerEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
final BonusManager manager = this;
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
clientData.setTickets(clientData.getTickets() - 1);
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
int modified = clientData.getRecord().store();
|
||||
|
||||
if (modified == 1)
|
||||
{
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
new SpinGui(getPlugin(), player, _rewardManager, manager).openInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "There was an error processing your request"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long timeTillRankBonus(Player player)
|
||||
{
|
||||
@ -272,8 +495,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
BonusAmount amount = new BonusAmount();
|
||||
amount.setTickets(1);
|
||||
amount.setBonusCoins(100);
|
||||
amount.setBonusExperience(100);
|
||||
amount.setGems(500);
|
||||
return amount;
|
||||
}
|
||||
|
||||
@ -283,15 +505,19 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
BonusAmount data = new BonusAmount();
|
||||
|
||||
if (rank.Has(Rank.MODERATOR))
|
||||
{
|
||||
data.setCoins(35000);
|
||||
}
|
||||
if (rank.Has(Rank.LEGEND))
|
||||
{
|
||||
data.setCoins(30000);
|
||||
}
|
||||
else if (rank.Has(Rank.ULTRA))
|
||||
else if (rank.Has(Rank.HERO))
|
||||
{
|
||||
data.setCoins(15000);
|
||||
}
|
||||
else if (rank.Has(Rank.HERO))
|
||||
else if (rank.Has(Rank.ULTRA))
|
||||
{
|
||||
data.setCoins(7500);
|
||||
}
|
||||
@ -301,10 +527,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
//VOTE
|
||||
|
||||
public void atteptVoteBonus(final Player player, final Consumer<Boolean> result)
|
||||
public void atteptVoteBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (timeTillRankBonus(player) > 0)
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
getRepository().attemptRankBonus(player, result);
|
||||
}
|
||||
|
||||
@ -327,7 +553,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
public void awardBonus(final Player player, BonusAmount amount)
|
||||
{
|
||||
BonusClientData bonusClient = Get(player);
|
||||
final BonusClientData bonusClient = Get(player);
|
||||
CoreClient coreClient = _clientManager.Get(player);
|
||||
|
||||
final int gems = amount.getTotalGems();
|
||||
@ -396,7 +622,14 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (tickets > 0)
|
||||
{
|
||||
bonusClient.setTickets(tickets + bonusClient.getTickets());
|
||||
// TODO database save
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
bonusClient.getRecord().store();
|
||||
}
|
||||
});
|
||||
UtilPlayer.message(player, F.main("Bonus", "Rewarded " + F.elem(tickets + " Carl Spin Ticket")));
|
||||
}
|
||||
|
||||
@ -578,4 +811,15 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
BonusClientData clientData = new BonusClientData(record);
|
||||
Set(playerName, clientData);
|
||||
}
|
||||
|
||||
public void addPendingExplosion(Player player, Object obj)
|
||||
{
|
||||
_pendingExplosions.add(obj);
|
||||
_pendingExplosionsPlayers.add(player);
|
||||
}
|
||||
|
||||
public PollManager getPollManager()
|
||||
{
|
||||
return _pollManager;
|
||||
}
|
||||
}
|
@ -6,11 +6,8 @@ import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
@ -19,6 +16,8 @@ import mineplex.core.recharge.Recharge;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.BonusRecord;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.TableField;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -60,10 +59,46 @@ public class BonusRepository extends RepositoryBase
|
||||
return record;
|
||||
}
|
||||
|
||||
public void attemptDailyBonus(final Player player, final Consumer<Boolean> result)
|
||||
public void getDailyStreakRecord(Callback<StreakRecord> callback)
|
||||
{
|
||||
getStreakRecord(Tables.bonus.maxDailyStreak, callback);
|
||||
}
|
||||
|
||||
public void getVoteStreakRecord(Callback<StreakRecord> callback)
|
||||
{
|
||||
getStreakRecord(Tables.bonus.maxVoteStreak, callback);
|
||||
}
|
||||
|
||||
private void getStreakRecord(final TableField<BonusRecord, Integer> field, final Callback<StreakRecord> callback)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Record2<String, Integer> record = jooq().select(Tables.accounts.name, field)
|
||||
.from(Tables.bonus.join(Tables.accounts).on(Tables.bonus.accountId.eq(Tables.accounts.id)))
|
||||
.orderBy(field.desc()).limit(1).fetchOne();
|
||||
|
||||
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (record.value1() != null && record.value2() != null)
|
||||
{
|
||||
callback.run(new StreakRecord(record.value1(), record.value2()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptDailyBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (!Recharge.Instance.usable(player, "AttemptDailyBonus")) {
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
@ -105,13 +140,13 @@ public class BonusRepository extends RepositoryBase
|
||||
if (pass)
|
||||
{
|
||||
_manager.Get(player).setDailyTime(new Timestamp(BonusManager.getSqlTime()));
|
||||
result.accept(true);
|
||||
result.run(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false);
|
||||
_manager.Get(player).setDailyTime(timeStamp);
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -120,23 +155,50 @@ public class BonusRepository extends RepositoryBase
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false);
|
||||
e.printStackTrace();
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptRankBonus(final Player player, final Consumer<Boolean> result)
|
||||
@Deprecated
|
||||
public void attemptPurchaseSpin(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final int newTickets = jooq().update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.sub(-1)).
|
||||
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
|
||||
|
||||
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptRankBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (!Recharge.Instance.usable(player, "AttemptRankBonus")) {
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
final int coins = _manager.getRankBonusAmount(player).getCoins();
|
||||
|
||||
if (coins == 0/* && gems == 0 */) {
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,29 +233,29 @@ public class BonusRepository extends RepositoryBase
|
||||
|
||||
if (pass)
|
||||
{
|
||||
result.accept(true);
|
||||
result.run(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 10, false, false);
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false);
|
||||
e.printStackTrace();
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void voteBonus(final Player player, final Consumer<Boolean> result)
|
||||
public void voteBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (!Recharge.Instance.usable(player, "AttemptVoteBonus"))
|
||||
{
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
@ -202,7 +264,7 @@ public class BonusRepository extends RepositoryBase
|
||||
final int gems = 0;
|
||||
|
||||
if (coins == 0/* && gems == 0 */) {
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -237,13 +299,13 @@ public class BonusRepository extends RepositoryBase
|
||||
_donationManager.RewardCoins(null, "Vote bonus", player.getName(), accountId, coins);
|
||||
_donationManager.RewardGems(null, "Vote bonus", player.getName(), player.getUniqueId(), gems);
|
||||
|
||||
result.accept(true);
|
||||
result.run(true);
|
||||
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.accept(false);
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.hub.bonuses;
|
||||
|
||||
public class StreakRecord
|
||||
{
|
||||
private String _playerName;
|
||||
private int _streak;
|
||||
|
||||
public StreakRecord(String playerName, int streak)
|
||||
{
|
||||
_playerName = playerName;
|
||||
_streak = streak;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public int getStreak()
|
||||
{
|
||||
return _streak;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.hub.bonuses;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.votifier.VotifierCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class VoteHandler implements CommandCallback
|
||||
{
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public VoteHandler(BonusManager bonusManager)
|
||||
{
|
||||
_bonusManager = bonusManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
VotifierCommand v = ((VotifierCommand) command);
|
||||
|
||||
Player player = UtilPlayer.searchExact(v.getPlayerName());
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
_bonusManager.handleVote(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package mineplex.hub.bonuses.animations;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AnimationCarl extends Animation
|
||||
{
|
||||
|
||||
private boolean _isDone;
|
||||
private Block _creeper;
|
||||
private long _startTime;
|
||||
private Object _type;
|
||||
private Player _player;
|
||||
|
||||
public AnimationCarl(Entity creeper)
|
||||
{
|
||||
_creeper = creeper.getLocation().getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if(_type instanceof String)
|
||||
{
|
||||
if (getTicks() < 40)
|
||||
{
|
||||
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 2, 0.5), new ItemStack(Material.EMERALD));
|
||||
|
||||
//Velocity
|
||||
long passed = System.currentTimeMillis() - _startTime;
|
||||
Vector vel = new Vector(Math.sin(passed/5d), 0, Math.cos(passed/5d));
|
||||
|
||||
UtilAction.velocity(gem, vel, Math.abs(Math.sin(passed/3000d)), false, 0, 0.2 + Math.abs(Math.cos(passed/3000d))*0.6, 1, false);
|
||||
|
||||
gem.setTicksLived(1170);
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
if(_type instanceof Reward)
|
||||
{
|
||||
RewardData rewardData = ((Reward)_type).getFakeRewardData(null);
|
||||
ItemStack itemStack = rewardData.getDisplayItem();
|
||||
if(itemStack.getType() == Material.PAPER)
|
||||
{
|
||||
itemStack = new ItemStack(Material.NETHER_STAR);
|
||||
}
|
||||
Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 2, 0.5), itemStack);
|
||||
|
||||
Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
|
||||
|
||||
UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
|
||||
|
||||
item.setTicksLived(1170);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinish() {
|
||||
_isDone = true;
|
||||
setTicks(0);
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return _isDone;
|
||||
}
|
||||
|
||||
public void setDone(boolean b)
|
||||
{
|
||||
_isDone = b;
|
||||
}
|
||||
|
||||
public void setTime(long time)
|
||||
{
|
||||
_startTime = time;
|
||||
}
|
||||
|
||||
public void setType(Object type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package mineplex.hub.bonuses.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
|
||||
public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
|
||||
BonusManager _plugin;
|
||||
|
||||
public AnimationCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "animation");
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
_plugin.addPendingExplosion(caller, "Test");
|
||||
_plugin.addPendingExplosion(caller, "Chiss");
|
||||
_plugin.addPendingExplosion(caller, "Phinary");
|
||||
_plugin.addPendingExplosion(caller, "xXVevzZXx");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package mineplex.hub.bonuses.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a player attempts to purchase a spin through carl
|
||||
*/
|
||||
public class CarlSpinnerEvent extends Event implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private boolean _cancelled;
|
||||
|
||||
public CarlSpinnerEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b)
|
||||
{
|
||||
_cancelled = b;
|
||||
}
|
||||
}
|
@ -5,11 +5,13 @@ import mineplex.core.reward.RewardManager;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
import mineplex.hub.bonuses.gui.buttons.CarlSpinButton;
|
||||
import mineplex.hub.bonuses.gui.buttons.DailyBonusButton;
|
||||
import mineplex.hub.bonuses.gui.buttons.PollButton;
|
||||
import mineplex.hub.bonuses.gui.buttons.RankBonusButton;
|
||||
import mineplex.hub.bonuses.gui.buttons.VoteButton;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.omg.CORBA._PolicyStub;
|
||||
|
||||
public class BonusGui extends SimpleGui
|
||||
{
|
||||
@ -22,13 +24,15 @@ public class BonusGui extends SimpleGui
|
||||
|
||||
this.manager = manager;
|
||||
|
||||
setItem(11, new VoteButton(plugin, player, this, manager));
|
||||
setItem(10, new VoteButton(plugin, player, this, manager));
|
||||
|
||||
setItem(13, new RankBonusButton(getPlugin(), player, this, manager));
|
||||
setItem(12, new RankBonusButton(getPlugin(), player, this, manager));
|
||||
|
||||
setItem(15, new DailyBonusButton(getPlugin(), player, this, manager));
|
||||
setItem(14, new DailyBonusButton(getPlugin(), player, this, manager));
|
||||
|
||||
setItem(31, new CarlSpinButton(getPlugin(), player, rewardManager));
|
||||
setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this));
|
||||
|
||||
setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,13 @@
|
||||
package mineplex.hub.bonuses.gui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gui.DisplayItem;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
@ -18,44 +15,97 @@ import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
import mineplex.hub.bonuses.gui.buttons.RewardButton;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class SpinGui extends SimpleGui
|
||||
{
|
||||
private static final int SELECT_OFFSET = 4;
|
||||
private static final int REWARDS_TO_GENERATE = 1000;
|
||||
private static final int HOPPER_SLOT = 22;
|
||||
private static final int CARL_SLOT = 40;
|
||||
private static final int[] LINE_NUMS = { -27, -18, -9, 9, 18 };
|
||||
private static final int HOPPER_SLOT = 4;
|
||||
private static final int CARL_SLOT = 22;
|
||||
private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ };
|
||||
private static final int STOP_SPINNER_AT = 75;
|
||||
|
||||
private int _tickCount;
|
||||
private RewardData _rewardData;
|
||||
private Reward _reward;
|
||||
private BonusManager _manager;
|
||||
private int _currentRewardIndex;
|
||||
private int _ticksThisSwap;
|
||||
private int _ticksPerSwap;
|
||||
private int _swapCount;
|
||||
private Reward[] _rewards;
|
||||
private boolean _stopped;
|
||||
private boolean _rewarded;
|
||||
private ArrayList<Integer> _ticks;
|
||||
private int _frame;
|
||||
private float _pitch;
|
||||
private int _stopSpinnerAt;
|
||||
|
||||
public SpinGui(Plugin plugin, Player player, RewardManager rewardManager)
|
||||
public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager)
|
||||
{
|
||||
super(plugin, player, "Carl's Spinner", 54);
|
||||
super(plugin, player, "Carl's Spinner", 27);
|
||||
|
||||
_manager = manager;
|
||||
|
||||
ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false);
|
||||
|
||||
setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER)));
|
||||
setItem(CARL_SLOT, new DisplayItem(carlItem));
|
||||
//setItem(CARL_SLOT, new DisplayItem(carlItem));
|
||||
|
||||
_rewards = new Reward[REWARDS_TO_GENERATE];
|
||||
_ticks = new ArrayList<>();
|
||||
_frame = 0;
|
||||
_pitch = 1;
|
||||
|
||||
for (int i = 0; i < REWARDS_TO_GENERATE; i++)
|
||||
{
|
||||
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.Spinner, true);
|
||||
}
|
||||
|
||||
_ticksPerSwap = 1;
|
||||
|
||||
_stopSpinnerAt = STOP_SPINNER_AT;
|
||||
|
||||
for (int i=0 ; i<40 ; i++)
|
||||
_ticks.add(1);
|
||||
|
||||
for (int i=0 ; i<20 ; i++)
|
||||
_ticks.add(2);
|
||||
|
||||
_ticksPerSwap = 3;
|
||||
for (int i=0 ; i<10 ; i++)
|
||||
_ticks.add(4);
|
||||
|
||||
for (int i=0 ; i<5 ; i++)
|
||||
_ticks.add(8);
|
||||
|
||||
if (Math.random() > 0.5)
|
||||
{
|
||||
_ticks.add(12);
|
||||
_stopSpinnerAt++;
|
||||
}
|
||||
|
||||
_reward = _rewards[_stopSpinnerAt % REWARDS_TO_GENERATE + 3];
|
||||
_rewardData = _reward.giveReward("Carls Spinner", getPlayer());
|
||||
}
|
||||
|
||||
private void tick()
|
||||
{
|
||||
|
||||
if(_stopped)
|
||||
return;
|
||||
|
||||
_ticksThisSwap++;
|
||||
|
||||
// Swap
|
||||
@ -65,15 +115,23 @@ public class SpinGui extends SimpleGui
|
||||
_swapCount++;
|
||||
|
||||
updateGui();
|
||||
float pitch = Math.max(-2, 2 - (_swapCount / 50f));
|
||||
// Bukkit.broadcastMessage(pitch + "");
|
||||
getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, pitch);
|
||||
if(_pitch == 1)
|
||||
_pitch = (float) 1.5;
|
||||
else if(_pitch == 1.5)
|
||||
_pitch = 2;
|
||||
else if(_pitch == 2)
|
||||
_pitch = 1;
|
||||
|
||||
getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch);
|
||||
|
||||
_currentRewardIndex++;
|
||||
|
||||
// Slow
|
||||
if (_swapCount % 10 == 0)
|
||||
_ticksPerSwap++;
|
||||
_ticksPerSwap = _ticks.get(_currentRewardIndex - 1);
|
||||
|
||||
if(_currentRewardIndex == _stopSpinnerAt)
|
||||
_stopped = true;
|
||||
|
||||
}
|
||||
|
||||
_tickCount++;
|
||||
@ -86,7 +144,7 @@ public class SpinGui extends SimpleGui
|
||||
int index = _currentRewardIndex + i;
|
||||
index = index % REWARDS_TO_GENERATE;
|
||||
|
||||
int slot = 27 + i;
|
||||
int slot = 9 + i;
|
||||
RewardData data = _rewards[index].getFakeRewardData(getPlayer());
|
||||
setItem(slot, new RewardButton(data));
|
||||
|
||||
@ -94,7 +152,7 @@ public class SpinGui extends SimpleGui
|
||||
for (int j = 0; j < LINE_NUMS.length; j++)
|
||||
{
|
||||
int paneSlot = slot + LINE_NUMS[j];
|
||||
if (paneSlot == HOPPER_SLOT || paneSlot == CARL_SLOT)
|
||||
if (paneSlot == HOPPER_SLOT)
|
||||
continue;
|
||||
|
||||
setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack()));
|
||||
@ -109,6 +167,72 @@ public class SpinGui extends SimpleGui
|
||||
return;
|
||||
|
||||
tick();
|
||||
checkIfDone();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void close(InventoryCloseEvent event)
|
||||
{
|
||||
if(_rewarded)
|
||||
return;
|
||||
|
||||
if(event.getPlayer() != getPlayer())
|
||||
return;
|
||||
|
||||
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You got " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " From Carl's Spinner."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Glass(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if(!_stopped)
|
||||
return;
|
||||
|
||||
if(!_rewarded)
|
||||
return;
|
||||
|
||||
if(_frame == 0)
|
||||
{
|
||||
setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
_frame++;
|
||||
}
|
||||
else if(_frame < 5)
|
||||
{
|
||||
setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
|
||||
setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
|
||||
setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
_frame++;
|
||||
}
|
||||
if(_frame == 6)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfDone()
|
||||
{
|
||||
if(!_stopped)
|
||||
return;
|
||||
|
||||
if(_rewarded)
|
||||
return;
|
||||
|
||||
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||
ItemStack item = getInventory().getItem(13);
|
||||
getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName()));
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You got " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " From Carl's Spinner."));
|
||||
_rewarded = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.hub.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -7,22 +9,25 @@ import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.hub.bonuses.gui.SpinGui;
|
||||
import mineplex.hub.bonuses.BonusClientData;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
|
||||
public class CarlSpinButton implements GuiItem
|
||||
{
|
||||
|
||||
private Plugin _plugin;
|
||||
private Player _player;
|
||||
private BonusManager _bonusManager;
|
||||
private RewardManager _rewardManager;
|
||||
|
||||
public CarlSpinButton(Plugin plugin, Player player, RewardManager rewardManager)
|
||||
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_player = player;
|
||||
_bonusManager = bonusManager;
|
||||
_rewardManager = rewardManager;
|
||||
}
|
||||
|
||||
@ -40,14 +45,41 @@ public class CarlSpinButton implements GuiItem
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
new SpinGui(_plugin, _player, _rewardManager).openInventory();
|
||||
BonusClientData client = _bonusManager.Get(_player);
|
||||
int tickets = client.getTickets();
|
||||
|
||||
if (tickets > 0)
|
||||
{
|
||||
_bonusManager.attemptCarlSpin(_player);
|
||||
}
|
||||
|
||||
// new SpinGui(_plugin, _player, _rewardManager).openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ShopItem item = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Try your Luck!" }, 1, false, false);
|
||||
BonusClientData client = _bonusManager.Get(_player);
|
||||
int tickets = client.getTickets();
|
||||
|
||||
return item;
|
||||
String name = (tickets > 0 ? C.cGreen : C.cRed) + C.Bold + "Carl's Spinner";
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
Material material = Material.SKULL_ITEM;
|
||||
byte data = (byte) 4;
|
||||
|
||||
lore.add(" ");
|
||||
if (tickets > 0)
|
||||
{
|
||||
lore.add(ChatColor.RESET + "Click to Spin");
|
||||
}
|
||||
else
|
||||
{
|
||||
lore.add(ChatColor.RESET + "You need a Carl Spin Ticket to Spin");
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.YELLOW + "Your Tickets: " + C.cWhite + tickets);
|
||||
|
||||
return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package mineplex.hub.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -19,6 +19,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.bonuses.BonusAmount;
|
||||
import mineplex.hub.bonuses.BonusClientData;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
import mineplex.hub.bonuses.StreakRecord;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -72,10 +73,9 @@ public class DailyBonusButton implements GuiItem, Listener
|
||||
_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 Consumer<Boolean>() {
|
||||
@SuppressWarnings("deprecation")
|
||||
_bonusManager.attemptDailyBonus(getPlayer(), _bonusManager.getDailyBonusAmount(_player), new Callback<Boolean>() {
|
||||
@Override
|
||||
public void accept(Boolean t)
|
||||
public void run(Boolean t)
|
||||
{
|
||||
if (t) {
|
||||
|
||||
@ -140,6 +140,7 @@ public class DailyBonusButton implements GuiItem, Listener
|
||||
|
||||
BonusAmount bonusAmount = _bonusManager.getDailyBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
lore.add(" ");
|
||||
|
||||
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getDailyStreak());
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak());
|
||||
@ -155,9 +156,13 @@ public class DailyBonusButton implements GuiItem, Listener
|
||||
}
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Record Holder: " + C.cWhite + "Phinary");
|
||||
lore.add(C.cYellow + "Streak: " + C.cWhite + "420");
|
||||
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);
|
||||
|
@ -1,8 +1,10 @@
|
||||
package mineplex.hub.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gui.GuiInventory;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
@ -53,32 +55,46 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
if (_poll != null)
|
||||
{
|
||||
|
||||
// Todo - Fix this!
|
||||
// getButtonMap().putAll(hard);
|
||||
|
||||
setItem(4, getQuestionItem(_poll.getQuestion()));
|
||||
setItem(13, getQuestionItem(_poll.getQuestion()));
|
||||
|
||||
int[] slots = even(9, _poll.getAnswers().length);
|
||||
|
||||
for (int i = 0; i < slots.length; i++)
|
||||
{
|
||||
|
||||
setItem(9 * 2 + slots[i], new AnswerItem(_poll, i));
|
||||
|
||||
AnswerItem item = new AnswerItem(_poll, i);
|
||||
setItem(9 * 3 + slots[i], item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
if (_poll == null)
|
||||
return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, "No polls!");
|
||||
{
|
||||
lore.add(C.cRed + "You've already voted on all of the polls!");
|
||||
return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + C.Bold + "Vote on Poll", lore);
|
||||
}
|
||||
else
|
||||
return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + _poll.getQuestion());
|
||||
{
|
||||
lore.add("");
|
||||
lore.add(C.cWhite + _poll.getQuestion());
|
||||
lore.add("");
|
||||
int i = 1;
|
||||
for(String str : _poll.getAnswers())
|
||||
{
|
||||
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
||||
i++;
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
|
||||
lore.add("");
|
||||
lore.add(C.cGreen + "Click to go to the vote page!");
|
||||
return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,8 +113,24 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
public GuiItem getQuestionItem(String question)
|
||||
{
|
||||
return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + "Question:",
|
||||
wrap(question)));
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add(C.cWhite + wrap(question));
|
||||
lore.add("");
|
||||
int i = 1;
|
||||
for(String str : _poll.getAnswers())
|
||||
{
|
||||
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
||||
i++;
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
|
||||
lore.add("");
|
||||
lore.add(C.cGreen + "Click to go to the vote page!");
|
||||
|
||||
return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + C.cGreen + C.Bold + "Vote on Poll",
|
||||
lore));
|
||||
}
|
||||
|
||||
public static String[] wrap(String text)
|
||||
@ -143,8 +175,10 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "" + (num + 1) + ":", wrap(getPoll()
|
||||
.getAnswers()[num]));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add(getPoll().getAnswers()[num]);
|
||||
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -155,8 +189,9 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
_pollManager.answerPoll(getPlayer(), _poll, num);
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory();
|
||||
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,9 @@
|
||||
package mineplex.hub.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -17,7 +17,6 @@ import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.bonuses.BonusAmount;
|
||||
import mineplex.hub.bonuses.BonusClientData;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -83,11 +82,10 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||
refreshItem();
|
||||
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||
_bonusManager.attemptRankBonus(getPlayer(), new Consumer<Boolean>()
|
||||
_bonusManager.attemptRankBonus(getPlayer(), new Callback<Boolean>()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void accept(Boolean t)
|
||||
public void run(Boolean t)
|
||||
{
|
||||
setItem();
|
||||
|
||||
@ -147,17 +145,23 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
if (!hasRank)
|
||||
{
|
||||
material = Material.COAL_BLOCK;
|
||||
itemName = C.cRed + ChatColor.BOLD + "Rank Bonus";
|
||||
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.WHITE + "Players with a rank get monthly rewards!");
|
||||
lore.add(ChatColor.WHITE + "Purchase at mineplex.com/shop");
|
||||
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
|
||||
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.WHITE + "Purchase a Rank at;");
|
||||
lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isAvailable())
|
||||
{
|
||||
material = Material.ENDER_CHEST;
|
||||
itemName = C.cGreen + C.Bold + "Rank Bonus";
|
||||
itemName = C.cGreen + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||
@ -165,7 +169,7 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
else
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + C.Bold + "Rank Bonus";
|
||||
itemName = C.cRed + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||
@ -187,13 +191,21 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
|
||||
public long timeLeft()
|
||||
{
|
||||
return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis();
|
||||
return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
{
|
||||
if (!hasRank)
|
||||
{
|
||||
UtilPlayer.message(getPlayer(), "----------------------------------------");
|
||||
UtilPlayer.message(getPlayer(), "");
|
||||
UtilPlayer.message(getPlayer(), "Purchase a Rank at the Mineplex Shop:");
|
||||
UtilPlayer.message(getPlayer(), C.cGreen + "www.mineplex.com/shop");
|
||||
UtilPlayer.message(getPlayer(), "");
|
||||
UtilPlayer.message(getPlayer(), "----------------------------------------");
|
||||
return false;
|
||||
}
|
||||
return (timeLeft() <= 0);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.bonuses.BonusAmount;
|
||||
import mineplex.hub.bonuses.BonusClientData;
|
||||
import mineplex.hub.bonuses.BonusManager;
|
||||
import mineplex.hub.bonuses.StreakRecord;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R4.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
|
||||
@ -58,7 +60,8 @@ public class VoteButton implements GuiItem, Listener {
|
||||
{
|
||||
//TODO get url from db
|
||||
_url = "http://minecraftservers.org/vote/121070";
|
||||
|
||||
|
||||
setItem();
|
||||
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||
}
|
||||
|
||||
@ -68,7 +71,6 @@ public class VoteButton implements GuiItem, Listener {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
@ -113,7 +115,7 @@ public class VoteButton implements GuiItem, Listener {
|
||||
|
||||
if (isAvailable())
|
||||
{
|
||||
material = Material.CHEST;
|
||||
material = Material.JUKEBOX;
|
||||
itemName = C.cGreen + C.Bold + "Vote Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
@ -134,6 +136,7 @@ public class VoteButton implements GuiItem, Listener {
|
||||
|
||||
BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
lore.add(" ");
|
||||
|
||||
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
|
||||
@ -149,9 +152,13 @@ public class VoteButton implements GuiItem, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Record Holder: " + C.cWhite + "Phinary");
|
||||
lore.add(C.cYellow + "Streak: " + C.cWhite + "420");
|
||||
StreakRecord streakRecord = _bonusManager.getVoteStreak();
|
||||
if (streakRecord != null)
|
||||
{
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
|
||||
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
|
||||
}
|
||||
|
||||
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
@ -165,6 +172,8 @@ public class VoteButton implements GuiItem, Listener {
|
||||
{
|
||||
if (_url == null)
|
||||
return false;
|
||||
System.out.println(timeLeft());
|
||||
|
||||
return (timeLeft() <= 0);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
pollData.setPollCooldown(5000);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/*@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
@ -88,7 +88,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
pollData.updatePollCooldown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public Poll getNextPoll(PlayerPollData pollData, Rank playerRank)
|
||||
{
|
||||
|
@ -0,0 +1,51 @@
|
||||
package mineplex.hub.profile.buttons;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.profile.gui.GUIProfile;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class ButtonMPS implements GuiItem
|
||||
{
|
||||
|
||||
private GUIProfile _profile;
|
||||
private Player _player;
|
||||
|
||||
public ButtonMPS(GUIProfile profile, Player player)
|
||||
{
|
||||
_profile = profile;
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
_profile.getPersonalManager().showHostMessage(_player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + "/hostserver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package mineplex.hub.profile.buttons;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.profile.gui.GUIProfile;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class ButtonPrefs implements GuiItem
|
||||
{
|
||||
|
||||
private GUIProfile _profile;
|
||||
private Player _player;
|
||||
|
||||
public ButtonPrefs(GUIProfile profile, Player player)
|
||||
{
|
||||
_profile = profile;
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
_profile.getPrefManager().openShop(_player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package mineplex.hub.profile.buttons;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.profile.gui.GUIProfile;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class ButtonStats implements GuiItem
|
||||
{
|
||||
|
||||
private GUIProfile _profile;
|
||||
private Player _player;
|
||||
|
||||
public ButtonStats(GUIProfile profile, Player player)
|
||||
{
|
||||
_profile = profile;
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
_profile.getAchievementManager().openShop(_player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats");
|
||||
SkullMeta meta = ((SkullMeta) item.getItemMeta());
|
||||
meta.setOwner(_player.getName());
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package mineplex.hub.profile.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.personalServer.PersonalServerManager;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.hub.profile.buttons.ButtonMPS;
|
||||
import mineplex.hub.profile.buttons.ButtonPrefs;
|
||||
import mineplex.hub.profile.buttons.ButtonStats;
|
||||
|
||||
public class GUIProfile extends SimpleGui
|
||||
{
|
||||
|
||||
private PreferencesManager _preferencesManager;
|
||||
private AchievementManager _achievementManager;
|
||||
private PersonalServerManager _personalServerManager;
|
||||
|
||||
public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager, PersonalServerManager personalServerManager)
|
||||
{
|
||||
super(plugin, player, "My Profile", 9*3);
|
||||
_preferencesManager = preferencesManager;
|
||||
_achievementManager = achievementManager;
|
||||
_personalServerManager = personalServerManager;
|
||||
|
||||
setItem(11, new ButtonStats(this, player));
|
||||
setItem(13, new ButtonMPS(this, player));
|
||||
setItem(15, new ButtonPrefs(this, player));
|
||||
}
|
||||
|
||||
public PreferencesManager getPrefManager()
|
||||
{
|
||||
return _preferencesManager;
|
||||
}
|
||||
|
||||
public AchievementManager getAchievementManager()
|
||||
{
|
||||
return _achievementManager;
|
||||
}
|
||||
|
||||
public PersonalServerManager getPersonalManager()
|
||||
{
|
||||
return _personalServerManager;
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
<orderEntry type="module" module-name="Mineplex.Core" />
|
||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||
</component>
|
||||
|
@ -8,27 +8,63 @@ import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.votifier.RedisVotifierCommand;
|
||||
import mineplex.core.votifier.VotifierCommand;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.data.PlayerStatus;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
/**
|
||||
* Created by shaun on 15-08-05.
|
||||
*/
|
||||
public class VotifierManager extends MiniPlugin
|
||||
{
|
||||
private RedisDataRepository<PlayerStatus> _usPlayerRepo;
|
||||
private RedisDataRepository<PlayerStatus> _euPlayerRepo;
|
||||
|
||||
public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super("Votifier", plugin);
|
||||
|
||||
_usPlayerRepo = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.US, PlayerStatus.class, "playerStatus");
|
||||
_euPlayerRepo = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.EU, PlayerStatus.class, "playerStatus");
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void handleVote(VotifierEvent event)
|
||||
{
|
||||
Vote vote = event.getVote();
|
||||
|
||||
RedisVotifierCommand command = new RedisVotifierCommand();
|
||||
|
||||
System.out.println("New Vote: " + vote.getUsername());
|
||||
|
||||
PlayerStatus usStatus = _usPlayerRepo.getElement(vote.getUsername());
|
||||
// VotifierCommand command = new VotifierCommand(vote.getUsername(), "PhiTest-1");
|
||||
// command.publish();
|
||||
|
||||
if (usStatus != null)
|
||||
{
|
||||
System.out.println("Found on US Server: " + usStatus.getServer());
|
||||
VotifierCommand command = new VotifierCommand(vote.getUsername(), usStatus.getServer());
|
||||
command.publish();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Not found on US Server!");
|
||||
}
|
||||
|
||||
PlayerStatus euStatus = _euPlayerRepo.getElement(vote.getUsername());
|
||||
if (euStatus != null)
|
||||
{
|
||||
System.out.println("Found on EU Server: " + euStatus.getServer());
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Not found on EU Server!");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user