Finalizing and improving the Carl spinner and adding creeper explosion animations.
This commit is contained in:
parent
e6519206af
commit
85c8e42f53
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ 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 mineplex.core.MiniClientPlugin;
|
||||
@ -14,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,6 +35,8 @@ 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;
|
||||
@ -32,15 +45,21 @@ import mineplex.hub.bonuses.gui.SpinGui;
|
||||
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;
|
||||
|
||||
@ -50,6 +69,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()
|
||||
{
|
||||
@ -91,6 +115,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private HologramManager _hologramManager;
|
||||
private RewardManager _rewardManager;
|
||||
private Npc _carlNpc;
|
||||
private AnimationCarl _animation;
|
||||
|
||||
// Streak
|
||||
private StreakRecord _dailyStreak;
|
||||
@ -107,7 +132,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_rewardManager = rewardManager;
|
||||
|
||||
// Hope to god this works!
|
||||
_canVote = true;
|
||||
_carlNpc = _npcManager.getNpcByName("Carl the Creeper");
|
||||
_animation = new AnimationCarl(_carlNpc.getEntity());
|
||||
_animation.setRunning(false);
|
||||
|
||||
clientManager.addStoredProcedureLoginProcessor(this);
|
||||
|
||||
@ -122,6 +150,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new GuiCommand(this));
|
||||
addCommand(new AnimationCommand(this));
|
||||
}
|
||||
|
||||
// Just keeping things up-to-date
|
||||
@ -176,7 +205,95 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
public void handleVote(Player player)
|
||||
{
|
||||
Bukkit.broadcastMessage("Recieved Vote: " + player.getName());
|
||||
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
|
||||
@ -253,6 +370,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
CarlSpinnerEvent event = new CarlSpinnerEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
final BonusManager manager = this;
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
@ -272,7 +390,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
new SpinGui(getPlugin(), player, _rewardManager).openInventory();
|
||||
new SpinGui(getPlugin(), player, _rewardManager, manager).openInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -374,6 +492,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
BonusAmount amount = new BonusAmount();
|
||||
amount.setTickets(1);
|
||||
amount.setGems(500);
|
||||
return amount;
|
||||
}
|
||||
|
||||
@ -383,15 +502,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);
|
||||
}
|
||||
@ -685,4 +808,10 @@ 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);
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public class CarlSpinButton implements GuiItem
|
||||
{
|
||||
_bonusManager.attemptCarlSpin(_player);
|
||||
}
|
||||
|
||||
// new SpinGui(_plugin, _player, _rewardManager).openInventory();
|
||||
}
|
||||
|
||||
|
@ -145,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: 7500 Coins");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero: 15000 Coins");
|
||||
lore.add(ChatColor.GREEN + "Legend: 30000 Coins");
|
||||
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!");
|
||||
@ -163,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) + "!");
|
||||
@ -185,7 +191,7 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
|
||||
public long timeLeft()
|
||||
{
|
||||
return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis();
|
||||
return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
|
Loading…
Reference in New Issue
Block a user