Merge pull request #163 in MIN/mineplex from feature/valentines-cosmetics to develop

* commit '57638ff68496b6f10012f8782633066b52a8a715':
  More work on valentines
  Valentines gifts
  Added love potion and hub sheep thing.
  Started on Love Potion system. Switching branches.
  Varius tweaks and changes.
  Added sheep mount to index.
  Added various cosmetic items for Valentines day.
This commit is contained in:
Shaun Bennett 2016-02-09 20:28:37 -06:00
commit f6e091f029
40 changed files with 1552 additions and 147 deletions

View File

@ -817,7 +817,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void openGui(PlayerInteractEntityEvent event)
{
if (!_enabled)
@ -831,23 +831,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
}
@EventHandler
public void openGui(EntityDamageByEntityEvent event)
{
if (!_enabled)
return;
if (event.getDamager() instanceof Player)
{
Player player = (Player) event.getDamager();
if (event.getEntity().equals(_carlNpc.getEntity()))
{
updateDailyStreak(player);
new BonusGui(_plugin, player, this, _rewardManager, _facebookManager).openInventory();
}
}
}
public static long getNextVoteTime(long time) {
Calendar calendar = Calendar.getInstance();

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -86,16 +85,16 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (gadget.getSet() != null)
{
itemLore.add(C.cBlack);
itemLore.add(C.cWhite + gadget.getSet().getName() + " Set;");
itemLore.add(C.cWhite + gadget.getSet().getName() + " Set");
//Elements
for (Gadget cur : gadget.getSet().getGadgets())
itemLore.add(" "+ (cur.ownsGadget(getPlayer()) ? C.cDGreen + '▪' : C.cDRed + '▪' ) + (cur.IsActive(getPlayer()) ? C.cGreen : C.cGray) + cur.GetName());
itemLore.add(" "+ (cur.ownsGadget(getPlayer()) ? C.cDGreen : C.cDRed) + "" + (cur.IsActive(getPlayer()) ? C.cGreen : C.cGray) + cur.GetName());
itemLore.add(C.cBlack);
//Bonus
itemLore.add(C.cWhite + gadget.getSet().getName() + " Set Bonus;");
itemLore.add(C.cWhite + gadget.getSet().getName() + " Set Bonus");
for (String bonus : gadget.getSet().getBonus())
itemLore.add(" " + (gadget.getSet().isActive(getPlayer()) ? C.cGreen : C.cGray) + bonus);
}
@ -127,6 +126,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
}
else if (gadget.GetCost(CurrencyType.Coins) == -6)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure");
}
//Rank Unlocks
else if (gadget.GetCost(CurrencyType.Coins) == -10)
{
@ -180,11 +184,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Left-Click to Enable");
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, this));
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false).hideInfo(), new ActivateGadgetButton(gadget, this));
}
else
{
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new ActivateGadgetButton(gadget, this));
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new ActivateGadgetButton(gadget, this));
}
return;
@ -206,7 +210,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
im.setLore(itemLore);
item.setItemMeta(im);
addButton(slot, new ShopItem(item, false, false), new DeactivateGadgetButton(gadget, this));
addButton(slot, new ShopItem(item, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this));
}
else
{
@ -215,7 +219,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
im.setLore(itemLore);
item.setItemMeta(im);
addButton(slot, new ShopItem(item, false, false), new ActivateGadgetButton(gadget, this));
addButton(slot, new ShopItem(item, false, false).hideInfo(), new ActivateGadgetButton(gadget, this));
}
}
else
@ -231,18 +235,18 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Purchase");
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new GadgetButton(gadget, this));
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this));
}
else if (gadget.GetCost(CurrencyType.Coins) > 0)
{
itemLore.add(C.cBlack);
itemLore.add(C.cRed + "Not enough Treasure Shards.");
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo());
}
else
{
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo());
}
}
@ -257,14 +261,14 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Disable");
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateGadgetButton(gadget, this));
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this));
}
else
{
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Enable");
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, this));
addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false).hideInfo(), new ActivateGadgetButton(gadget, this));
}
}
else
@ -280,18 +284,18 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Purchase");
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new GadgetButton(gadget, this));
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this));
}
else if (gadget.GetCost(CurrencyType.Coins) > 0)
{
itemLore.add(C.cBlack);
itemLore.add(C.cRed + "Not enough Treasure Shards.");
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo());
}
else
{
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo());
}
}
}

View File

@ -87,6 +87,11 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
}
else if (mount.GetCost(CurrencyType.Coins) == -6)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure");
}
//Rank Unlocks
else if (mount.GetCost(CurrencyType.Coins) == -10)
{
@ -110,7 +115,6 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
}
}
if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.GetName()))
{
if (mount.GetActive().containsKey(getPlayer()))
@ -141,18 +145,18 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Purchase");
addButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this));
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 7, mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this));
}
else if (mount.GetCost(CurrencyType.Coins) > 0)
{
itemLore.add(C.cBlack);
itemLore.add(C.cRed + "Not enough Treasure Shards.");
setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte) 7, mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
else
{
setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte) 7, mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import mineplex.core.gadget.gadgets.item.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -32,16 +33,64 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.gadgets.arrowtrail.*;
import mineplex.core.gadget.gadgets.death.*;
import mineplex.core.gadget.gadgets.doublejump.*;
import mineplex.core.gadget.gadgets.hat.*;
import mineplex.core.gadget.gadgets.item.*;
import mineplex.core.gadget.gadgets.morph.*;
import mineplex.core.gadget.gadgets.outfit.*;
import mineplex.core.gadget.gadgets.particle.*;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHearts;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan;
import mineplex.core.gadget.gadgets.death.DeathCandyCane;
import mineplex.core.gadget.gadgets.death.DeathFrostLord;
import mineplex.core.gadget.gadgets.death.DeathHearts;
import mineplex.core.gadget.gadgets.death.DeathTitan;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHearts;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan;
import mineplex.core.gadget.gadgets.hat.HatCoal;
import mineplex.core.gadget.gadgets.hat.HatGrinch;
import mineplex.core.gadget.gadgets.hat.HatPresent;
import mineplex.core.gadget.gadgets.hat.HatRudolph;
import mineplex.core.gadget.gadgets.hat.HatSanta;
import mineplex.core.gadget.gadgets.hat.HatSnowman;
import mineplex.core.gadget.gadgets.morph.MorphBat;
import mineplex.core.gadget.gadgets.morph.MorphBlaze;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphBunny;
import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphPig;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphTitan;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.morph.MorphWither;
import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitLeggings;
import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitBoots;
import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitLeggings;
import mineplex.core.gadget.gadgets.outfit.OutfitTeam;
import mineplex.core.gadget.gadgets.particle.ParticleCandyCane;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleEnchant;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.ParticleFrostLord;
import mineplex.core.gadget.gadgets.particle.ParticleGreen;
import mineplex.core.gadget.gadgets.particle.ParticleHeart;
import mineplex.core.gadget.gadgets.particle.ParticleHelix;
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
import mineplex.core.gadget.gadgets.particle.ParticleRain;
import mineplex.core.gadget.gadgets.particle.ParticleTitan;
import mineplex.core.gadget.set.SetCandyCane;
import mineplex.core.gadget.set.SetFrostLord;
import mineplex.core.gadget.set.SetLove;
import mineplex.core.gadget.set.SetRaveSuit;
import mineplex.core.gadget.set.SetSpaceSuit;
import mineplex.core.gadget.set.SetTitan;
@ -59,6 +108,7 @@ import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
@ -75,6 +125,7 @@ public class GadgetManager extends MiniPlugin
private ProjectileManager _projectileManager;
private AchievementManager _achievementManager;
private MountManager _mountManager;
private PacketHandler _packetManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -89,7 +140,8 @@ public class GadgetManager extends MiniPlugin
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager)
DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager,
PacketHandler packetHandler)
{
super("Gadget Manager", plugin);
@ -102,6 +154,7 @@ public class GadgetManager extends MiniPlugin
_blockRestore = blockRestore;
_projectileManager = projectileManager;
_achievementManager = achievementManager;
_packetManager = packetHandler;
_mountManager = mountManager;
CreateGadgets();
@ -114,6 +167,7 @@ public class GadgetManager extends MiniPlugin
addSet(new SetFrostLord(this));
addSet(new SetCandyCane(this));
addSet(new SetTitan(this));
addSet(new SetLove(this));
//Costumes
addSet(new SetRaveSuit(this));
@ -139,6 +193,9 @@ public class GadgetManager extends MiniPlugin
addGadget(new ItemCoal(this));
addGadget(new ItemFreezeCannon(this));
addGadget(new ItemSnowball(this));
addGadget(new ItemBow(this));
addGadget(new ItemLovePotion(this));
addGadget(new ItemFlowerGift(this));
// Costume
addGadget(new OutfitRaveSuitHelmet(this));
@ -192,16 +249,19 @@ public class GadgetManager extends MiniPlugin
addGadget(new ArrowTrailFrostLord(this));
addGadget(new ArrowTrailTitan(this));
addGadget(new ArrowTrailCandyCane(this));
addGadget(new ArrowTrailHearts(this));
// Death Effect
addGadget(new DeathFrostLord(this));
addGadget(new DeathTitan(this));
addGadget(new DeathCandyCane(this));
addGadget(new DeathHearts(this));
// Double Jump
addGadget(new DoubleJumpFrostLord(this));
addGadget(new DoubleJumpTitan(this));
addGadget(new DoubleJumpCandyCane(this));
addGadget(new DoubleJumpHearts(this));
// Hat
addGadget(new HatSanta(this));
@ -407,9 +467,9 @@ public class GadgetManager extends MiniPlugin
return _inventoryManager;
}
public boolean collideEvent(Gadget gadget, Player other)
public boolean collideEvent(Player shooter, Gadget gadget, Player other)
{
GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(gadget, other);
GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(shooter, gadget, other);
Bukkit.getServer().getPluginManager().callEvent(collideEvent);
@ -420,6 +480,11 @@ public class GadgetManager extends MiniPlugin
{
return _blockRestore;
}
public PacketHandler getPacketManager()
{
return _packetManager;
}
@EventHandler
public void setMoving(PlayerMoveEvent event)

View File

@ -1,22 +1,25 @@
package mineplex.core.gadget.event;
import mineplex.core.gadget.types.Gadget;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.gadget.types.Gadget;
public class GadgetCollideEntityEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _gadgetHolder;
private Gadget _gadget;
private Entity _other;
private boolean _cancelled = false;
public GadgetCollideEntityEvent(Gadget gadget, Entity other)
public GadgetCollideEntityEvent(Player player, Gadget gadget, Entity other)
{
_gadgetHolder = player;
_gadget = gadget;
_other = other;
}
@ -30,6 +33,11 @@ public class GadgetCollideEntityEvent extends Event
{
return handlers;
}
public Player getPlayer()
{
return _gadgetHolder;
}
public Gadget getGadget()
{

View File

@ -0,0 +1,51 @@
package mineplex.core.gadget.gadgets.arrowtrail;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ArrowEffectGadget;
public class ArrowTrailHearts extends ArrowEffectGadget
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
public ArrowTrailHearts(GadgetManager manager)
{
super(manager, "Arrows of Cupid",
UtilText.splitLineToArray(C.cGray + "Tether your love to an arrow, then spear someone with it. Maybe they'll fall in love!", LineFormat.LORE),
1,
Material.APPLE, (byte) 0);
}
@Override
public void doTrail(Arrow arrow)
{
UtilParticle.PlayParticleToAll(ParticleType.HEART, arrow.getLocation(), .1F, .1F, .1F, 0F, 1, ViewDist.LONGER);
byte data = 14;
if (UtilMath.random.nextDouble() > .5)
data = 6;
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, data), arrow.getLocation(), 0, 0, 0, 0.0f, 5, ViewDist.NORMAL);
}
@Override
public void doHitEffect(Arrow arrow)
{
UtilParticle.PlayParticleToAll(ParticleType.HEART, arrow.getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), arrow.getLocation(), .5F, .5F, .5F, 0.0f, 5, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), arrow.getLocation(), .5F, .5F, .5F, 0.0f, 5, ViewDist.NORMAL);
}
}

View File

@ -0,0 +1,65 @@
package mineplex.core.gadget.gadgets.death;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.blood.BloodEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.DeathEffectGadget;
public class DeathHearts extends DeathEffectGadget
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
public DeathHearts(GadgetManager manager)
{
super(manager, "Broken Hearted",
UtilText.splitLineToArray(C.cGray + "Nothing hurts more than having your heart broken. Apart from being killed, that is.", LineFormat.LORE),
1, Material.DOUBLE_PLANT, (byte) 4);
}
@EventHandler
public void onBlood(BloodEvent event)
{
if (IsActive(event.getPlayer()))
event.setItem(Material.AIR, (byte) 0);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onParticles(BloodEvent event)
{
if (event.isCancelled())
return;
if (IsActive(event.getPlayer()))
{
Location loc = event.getLocation().clone().add(0, .5, 0);
UtilParticle.PlayParticleToAll(ParticleType.HEART, loc, 0F, 0F, 0F, 0F, 1, ViewDist.NORMAL);
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
loc.add(0, .2, 0);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), loc, .1F, .1F, .1F, 0.0f, 5, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), loc, .1F, .1F, .1F, 0.0f, 5, ViewDist.NORMAL);
}
}, 10);
}
}
}

View File

@ -0,0 +1,38 @@
package mineplex.core.gadget.gadgets.doublejump;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
public class DoubleJumpHearts extends DoubleJumpEffectGadget
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
public DoubleJumpHearts(GadgetManager manager)
{
super(manager, "Wings of Love",
UtilText.splitLineToArray(C.cGray + "Nothing hurts more than having your heart broken. Apart from being killed, that is.", LineFormat.LORE),
1, Material.RED_MUSHROOM, (byte) 0);
}
@Override
public void doEffect(Player player)
{
UtilParticle.PlayParticleToAll(ParticleType.HEART, player.getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), player.getLocation(), .5F, .5F, .5F, 0.0f, 2, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), player.getLocation(), .5F, .5F, .5F, 0.0f, 2, ViewDist.NORMAL);
}
}

View File

@ -110,7 +110,7 @@ public class ItemBatGun extends ItemGadget
if (UtilEnt.hitBox(bat.getLocation(), other, 2, null))
{
if (Manager.collideEvent(this, other))
if (Manager.collideEvent(cur, this, other))
continue;
//Damage Event

View File

@ -0,0 +1,220 @@
package mineplex.core.gadget.gadgets.item;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
public class ItemBow extends ItemGadget
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
private HashSet<Snowball> _arrows = new HashSet<Snowball>();
private boolean _spawning = false;
private String[] _responses = new String[]
{
"Do you feel the love?",
"Are you in love?",
"(I think they like you!)",
"Ahhh. Young love!",
"Maybe they'll bring you a rose!",
"You should go say Hi to them.",
"They look nice.",
"I love love!",
"Go get 'em, tiger!",
"Don't be TOO flirty, now.",
"That was one of my good arrows!",
"Do you believe in love at first sight?",
"Never gunna give you up, never gunna let you down.",
"I approve this message!",
};
private IPacketHandler _packetHandler = new IPacketHandler()
{
@Override
public void handle(PacketInfo packetInfo)
{
if (_spawning)
{
packetInfo.setCancelled(true);
return;
}
PacketPlayOutSpawnEntity packet = (PacketPlayOutSpawnEntity) packetInfo.getPacket();
for (Snowball arrow : _arrows)
{
if (arrow.getEntityId() == packet.a)
{
packetInfo.setCancelled(true);
return;
}
}
}
};
@SuppressWarnings("unchecked")
public ItemBow(GadgetManager manager)
{
super(manager, "Cupid's Arrows",
UtilText.splitLineToArray(C.cGray + "This symbol of love will live on with you forever! Mainly because we couldn't attach the cupid wings to it. I guess duct tape can't fix everything!", LineFormat.LORE),
1, Material.BOW, (byte) 0, 1000, new Ammo("Cupid Arrow", "Cupid's Arrows", Material.ARROW, (byte) 0, UtilText.splitLineToArray(C.cGray + "Use these arrows to shoot love into people's hearts!", LineFormat.LORE), 1, 15));
Manager.getPacketManager().addPacketHandler(_packetHandler, PacketPlayOutSpawnEntity.class);
}
@Override
public void ActivateCustom(Player player)
{
_spawning = true;
Snowball arrow = player.launchProjectile(Snowball.class);
_spawning = false;
_arrows.add(arrow);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
for (Snowball arrow : new HashSet<Snowball>(_arrows))
{
if (!arrow.isValid())
{
_arrows.remove(arrow);
continue;
}
UtilParticle.PlayParticleToAll(ParticleType.HEART, arrow.getLocation(), 0F, 0F, 0F, 0F, 1, ViewDist.LONGER);
}
}
}
@EventHandler
public void onHit(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Snowball))
return;
Snowball arrow = (Snowball) event.getEntity();
if (!_arrows.contains(arrow))
return;
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
if (_arrows.remove(arrow))
{
arrow.remove();
UtilPlayer.message((Player) arrow.getShooter(), F.main(C.cRed + "Cupid", "You missed the shot!"));
}
}
}, 1);
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Snowball))
return;
Snowball arrow = (Snowball) event.getDamager();
if (!_arrows.contains(arrow))
return;
_arrows.remove(arrow);
arrow.remove();
Player shooter = (Player) arrow.getShooter();
if (event.getEntity() instanceof Creeper && event.getEntity().getCustomName().equalsIgnoreCase(C.cGreenB + "Carl the Creeper"))
{
UtilPlayer.message(shooter, F.main(C.cRed + "Cupid", "Nobody will ever replace Carla."));
return;
}
// Effects
if (event.getEntity() instanceof Player)
{
if (event.getEntity() == shooter)
{
UtilPlayer.message(shooter, F.main(C.cRed + "Cupid", "We've all been there."));
return;
}
UtilPlayer.message(shooter, F.main(C.cRed + "Cupid", "You hit " + F.name(UtilEnt.getName(event.getEntity())) + " with an arrow! I wonder how they're feeling..."));
((Player) event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 40, false, false));
UtilPlayer.message(event.getEntity(), F.main(C.cRed + "Cupid", F.name(UtilEnt.getName(shooter)) + " hit you with an arrow! " + UtilMath.randomElement(_responses)));
}
UtilParticle.PlayParticleToAll(ParticleType.HEART, event.getEntity().getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), event.getEntity().getLocation(), .5F, .5F, .5F, 0.0f, 5, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), event.getEntity().getLocation(), .5F, .5F, .5F, 0.0f, 5, ViewDist.NORMAL);
shooter.playSound(shooter.getLocation(), Sound.ORB_PICKUP, 0.5f, 0.5f);
// Entity damaged = event.getEntity();
// AxisAlignedBB bb = ((CraftEntity) damaged).getHandle().getBoundingBox();
//
// final Location loc = damaged.getLocation().clone();
// final AxisAlignedBB bounding = new AxisAlignedBB(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f); // Clone it
//
// int i = 0;
// for (double rise = bounding.b ; rise < bounding.e ; rise += .2)
// {
// i++;
//
// final float y = (float) (rise - bounding.b);
// final float x = (float) (Math.sin(y) * 2);
// final float z = (float) (Math.cos(y) * 2);
//
// Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
// {
// @Override
// public void run()
// {
// UtilParticle.PlayParticleToAll(ParticleType.HEART, loc.clone().add(x, y, z), 0F, 0F, 0F, 0F, 1, ViewDist.LONGER);
// }
// }, i);
// }
}
}

View File

@ -69,7 +69,7 @@ public class ItemCoal extends ItemGadget
, -1, Material.COAL, (byte) 0, 1000, new Ammo("Coal", "1 Piece of Coal", Material.COAL, (byte) 0, new String[]
{
C.cDGray + "Exclusive Coal!",
C.cDGray + "Earned by beeing naughty"
C.cDGray + "Earned by being naughty"
}
, -1, 1));
}

View File

@ -68,7 +68,7 @@ public class ItemFleshHook extends ItemGadget implements IThrown
return;
if (target instanceof Player)
if (Manager.collideEvent(this, (Player) target))
if (Manager.collideEvent(player, this, (Player) target))
return;
//Pull

View File

@ -0,0 +1,115 @@
package mineplex.core.gadget.gadgets.item;
import mineplex.core.common.util.*;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.valentines.event.AttemptGiftEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class ItemFlowerGift extends ItemGadget
{
public ItemFlowerGift(GadgetManager manager)
{
super(manager,
"Valentines Gift",
UtilText.splitLineToArray(C.cGray + "Maybe you can win over Chiss' heart with this!", LineFormat.LORE),
1,
Material.RED_ROSE,
(byte) 0,
2000,
new Ammo("Valentines Gift", "Valentines Gift", Material.RED_ROSE, (byte) 0, UtilText.splitLineToArray(C.cGray + "Maybe you can win over Chiss' heart with this!", LineFormat.LORE), 1, 10));
}
@Override
public void ActivateCustom(Player player)
{
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInteract(PlayerInteractAtEntityEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilGear.isMat(player.getItemInHand(), GetDisplayMaterial()))
return;
if (!hasAmmo(player))
{
UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left."));
ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this);
Bukkit.getServer().getPluginManager().callEvent(ammoEvent);
return;
}
//Recharge
if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"))
{
UtilInv.Update(player);
return;
}
if (event.getRightClicked() instanceof Player)
{
Player to = ((Player) event.getRightClicked());
AttemptGiftEvent giftEvent = new AttemptGiftEvent(player, to);
Bukkit.getPluginManager().callEvent(giftEvent);
}
else
{
UtilPlayer.message(player, F.main("Gadget", "You used " + F.elem(GetName()) + " on " + F.name(event.getRightClicked().getName()) + ". It's not very effective..."));
}
event.setCancelled(true);
}
@Override
@EventHandler
public void Activate(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (!IsActive(event.getPlayer()))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), GetDisplayMaterial()))
return;
//Recharge
if (!Recharge.Instance.use(event.getPlayer(), GetName(), GetName(), _recharge, false, true, false, true, "Cosmetics"))
return;
if (!hasAmmo(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Gadget", "You do not have any " + GetName() + " left."));
ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this);
Bukkit.getServer().getPluginManager().callEvent(ammoEvent);
return;
}
event.setCancelled(true);
// Logic is handled in onInteract (so we can cancel interact events on npc's)
UtilPlayer.message(event.getPlayer(), F.main("Gift", "Nothing happened... Maybe I should try giving this to someone?!"));
}
}

View File

@ -0,0 +1,183 @@
package mineplex.core.gadget.gadgets.item;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
public class ItemLovePotion extends ItemGadget
{
/**
* Created by: Mysticate
* Timestamp: February 6, 2016
*/
public ItemLovePotion(GadgetManager manager)
{
super(
manager,
"Love Potion",
UtilText.splitLineToArray(C.cGray + "It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE),
1,
Material.POTION,
(byte) 8233,
20000,
new Ammo(
"Love Potion",
"Love Potion",
Material.POTION,
(byte) 8233,
UtilText.splitLineToArray(C.cGray + "It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE),
1,
16)
);
}
@Override
public void ApplyItem(Player player, boolean inform)
{
Manager.removeGadgetType(player, GadgetType.Item);
_active.add(player);
List<String> itemLore = new ArrayList<String>();
itemLore.addAll(Arrays.asList(GetDescription()));
itemLore.add(C.cBlack);
itemLore.add(C.cWhite + "Your Ammo : " + Manager.getInventoryManager().Get(player).getItemCount(GetName()));
player.getInventory().setItem(Manager.getActiveItemSlot(), new ItemBuilder(GetDisplayMaterial(), GetDisplayData()).setTitle(F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())).setHideInfo(true).build());
if (inform)
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + "."));
}
@EventHandler
public void onInteract(PlayerInteractEntityEvent event)
{
Player player = event.getPlayer();
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), GetDisplayMaterial()))
return;
if (!IsActive(player))
return;
if (!Recharge.Instance.use(player, "Interact Love Potion", 1000, false, false))
return;
event.setCancelled(true);
//Stock
if (!hasAmmo(player))
{
UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left."));
ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this);
Bukkit.getServer().getPluginManager().callEvent(ammoEvent);
return;
}
if (!Recharge.Instance.usable(player, GetName()))
{
UtilInv.Update(player);
return;
}
GadgetCollideEntityEvent gadgetEvent = new GadgetCollideEntityEvent(player, this, event.getRightClicked());
gadgetEvent.setCancelled(true); // Pre cancel
Bukkit.getPluginManager().callEvent(gadgetEvent);
if (gadgetEvent.isCancelled())
return;
Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"); // Cooldown
Manager.getInventoryManager().addItemToInventory(player, GetName(), -1);
player.getInventory().setItem(Manager.getActiveItemSlot(), new ItemBuilder(GetDisplayMaterial(), GetDisplayData()).setTitle(F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())).setHideInfo(true).build());
}
@EventHandler
public void Activate(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), this.GetDisplayMaterial()))
return;
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!Recharge.Instance.use(player, "Interact Love Potion", 500, false, false))
return;
event.setCancelled(true);
//Stock
if (!hasAmmo(player))
{
UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left."));
ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this);
Bukkit.getServer().getPluginManager().callEvent(ammoEvent);
return;
}
//Recharge
if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"))
{
UtilInv.Update(player);
return;
}
UtilPlayer.message(player, F.main("Potion", "You drank the love potion, because why not?"));
Manager.getInventoryManager().addItemToInventory(player, GetName(), -1);
player.getInventory().setItem(Manager.getActiveItemSlot(), new ItemBuilder(GetDisplayMaterial(), GetDisplayData()).setTitle(F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())).setHideInfo(true).build());
ActivateCustom(event.getPlayer());
}
@Override
public void ActivateCustom(Player player)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 40, false, false));
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.gadget.gadgets.item;
import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -12,6 +10,7 @@ import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
@ -22,7 +21,7 @@ import mineplex.core.gadget.types.ItemGadget;
public class ItemSnowball extends ItemGadget
{
private HashSet<Snowball> _snowballs = new HashSet<>();
private NautHashMap<Snowball, Player> _snowballs = new NautHashMap<Snowball, Player>();
public ItemSnowball(GadgetManager manager)
{
@ -40,16 +39,21 @@ public class ItemSnowball extends ItemGadget
public void ActivateCustom(Player player)
{
Snowball ball = player.launchProjectile(Snowball.class);
_snowballs.add(ball);
_snowballs.put(ball, player);
ball.getWorld().playSound(ball.getLocation(), Sound.CHICKEN_EGG_POP, 1f, 0.3f);
}
@EventHandler
public void onHit(EntityDamageByEntityEvent event)
{
if(!_snowballs.contains(event.getDamager())) return;
if (!(event.getDamager() instanceof Snowball))
return;
GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(this, event.getEntity());
Snowball ball = (Snowball) event.getDamager();
if(!_snowballs.containsKey(ball)) return;
GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowballs.remove(ball), this, event.getEntity());
if(gevent.isCancelled()) return;

View File

@ -16,11 +16,11 @@ import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
@ -29,7 +29,7 @@ import mineplex.core.updater.event.UpdateEvent;
public class ItemTNT extends ItemGadget
{
private HashSet<TNTPrimed> _tnt = new HashSet<TNTPrimed>();
private HashMap<TNTPrimed, Player> _tnt = new HashMap<TNTPrimed, Player>();
public ItemTNT(GadgetManager manager)
{
@ -46,7 +46,7 @@ public class ItemTNT extends ItemGadget
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
tnt.setYield(0.0F); // Added in order to prevent water from being evaporated.
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false);
_tnt.add(tnt);
_tnt.put(tnt, player);
//Inform
UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill(GetName()) + "."));
@ -58,13 +58,15 @@ public class ItemTNT extends ItemGadget
if (!(event.getEntity() instanceof TNTPrimed))
return;
if (!_tnt.remove(event.getEntity()))
if (!_tnt.containsKey(event.getEntity()))
return;
Player killer = _tnt.get(event.getEntity());
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 8);
for (Player player : players.keySet())
{
if (Manager.collideEvent(this, player))
if (Manager.collideEvent(killer, this, player))
continue;
double mult = players.get(player);
@ -84,16 +86,12 @@ public class ItemTNT extends ItemGadget
if (event.getType() != UpdateType.FAST)
return;
Iterator<TNTPrimed> tntIterator = _tnt.iterator();
while (tntIterator.hasNext())
for (TNTPrimed tnt : new HashSet<TNTPrimed>(_tnt.keySet()))
{
TNTPrimed tnt = tntIterator.next();
if (!tnt.isValid() || tnt.getTicksLived() > 200)
{
tnt.remove();
tntIterator.remove();
_tnt.remove(tnt);
}
}
}

View File

@ -113,7 +113,7 @@ public class MorphCreeper extends MorphGadget
if (other.equals(player))
continue;
if (Manager.collideEvent(this, other))
if (Manager.collideEvent(player, this, other))
continue;
double mult = players.get(other);

View File

@ -135,7 +135,7 @@ public class MorphPig extends MorphGadget
if (UtilMath.offset(player, other) > range)
continue;
if (Manager.collideEvent(this, other))
if (Manager.collideEvent(player, this, other))
continue;
//Cooldown

View File

@ -143,7 +143,7 @@ public class MorphSnowman extends MorphGadget
if (!_snowball.containsKey(proj))
return;
GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(this, event.getEntity());
GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowball.remove(proj), this, event.getEntity());
if(gevent.isCancelled()) return;

View File

@ -139,7 +139,7 @@ public class MorphTitan extends MorphGadget
for (Player ent : players.keySet())
{
if (ent instanceof Player)
if (Manager.collideEvent(this, (Player)ent))
if (Manager.collideEvent(event.GetPlayer(), this, (Player)ent))
continue;
double mult = players.get(ent);

View File

@ -116,7 +116,7 @@ public class MorphVillager extends MorphGadget implements IThrown
return;
if (target instanceof Player)
if (Manager.collideEvent(this, (Player) target))
if (Manager.collideEvent((Player) data.GetThrower(), this, (Player) target))
return;
//Pull

View File

@ -128,7 +128,7 @@ public class MorphWither extends MorphGadget
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 6);
for (Player player : players.keySet())
{
if (Manager.collideEvent(this, player))
if (Manager.collideEvent((Player) skull.getShooter(), this, player))
continue;
double mult = players.get(player);

View File

@ -33,10 +33,10 @@ public class ParticleHeart extends ParticleGadget {
public ParticleHeart(GadgetManager manager)
{
super(manager, "I Heart You",
UtilText.splitLineToArray(C.cGray + "Show off how much you love Mineplex and everyone on it!", LineFormat.LORE),
super(manager, "Heartfelt Halo",
UtilText.splitLineToArray(C.cGray + "Share the love you feel in your heart with everybody near you!", LineFormat.LORE),
-2,
Material.APPLE, (byte)0);
Material.APPLE, (byte)0, "I Heart You");
}
@EventHandler

View File

@ -0,0 +1,25 @@
package mineplex.core.gadget.set;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHearts;
import mineplex.core.gadget.gadgets.death.DeathHearts;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHearts;
import mineplex.core.gadget.gadgets.particle.ParticleHeart;
import mineplex.core.gadget.types.GadgetSet;
public class SetLove extends GadgetSet
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
public SetLove(GadgetManager manager)
{
super(manager, "Lovely!", "Coming Soon",
manager.getGadget(ArrowTrailHearts.class),
manager.getGadget(DeathHearts.class),
manager.getGadget(DoubleJumpHearts.class),
manager.getGadget(ParticleHeart.class));
}
}

View File

@ -103,6 +103,13 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
{
System.out.println("Add item to Inventory FAILED for " + player.getName());
}
else
{
if (_items.containsKey(item))
{
Get(player).addItem(new ClientItem(_items.get(item), count));
}
}
if (callback != null)
callback.run(success);

View File

@ -32,6 +32,7 @@ import mineplex.core.mount.types.MountSlime;
import mineplex.core.mount.types.MountSpider;
import mineplex.core.mount.types.MountTitan;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.MountValentinesSheep;
import mineplex.core.mount.types.MountZombie;
public class MountManager extends MiniPlugin
@ -70,6 +71,7 @@ public class MountManager extends MiniPlugin
_types.add(new MountZombie(this));
_types.add(new MountTitan(this));
_types.add(new MountBabyReindeer(this));
_types.add(new MountValentinesSheep(this));
//_types.add(new MountSheep(this));
}

View File

@ -0,0 +1,97 @@
package mineplex.core.mount.types;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountValentinesSheep extends HorseMount
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
public MountValentinesSheep(MountManager manager)
{
super(manager, "Loving Sheeples",
UtilText.splitLineToArray(C.cGray + "This symbol of love will live on with you forever! Mainly because we couldn't attach the cupid wings to it. I guess duct tape can't fix everything!", LineFormat.LORE),
Material.WOOL, (byte) 6, 1, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 1.0, null);
}
@Override
public void EnableCustom(Player player)
{
super.EnableCustom(player);
Horse horse = GetActive().get(player).getEntity();
UtilEnt.silence(horse, true);
DisguiseSheep disguise = new DisguiseSheep(horse);
disguise.setColor(DyeColor.PINK);
Manager.getDisguiseManager().disguise(disguise);
}
@EventHandler
public void doAnimations(UpdateEvent event)
{
for (SingleEntityMountData<Horse> ent : GetActive().values())
{
if (!ent.getEntity().isValid())
continue;
if (event.getType() == UpdateType.FASTEST)
{
Location loc = ent.getEntity().getLocation().clone().add(0, .5, 0);
UtilParticle.PlayParticleToAll(ParticleType.HEART, loc, .5F, .4F, .5F, 0F, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), loc, .5F, .4F, .5F, 0.0f, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), loc, .5F, .4F, .5F, 0.0f, 1, ViewDist.NORMAL);
}
else if (event.getType() == UpdateType.FAST)
{
DisguiseBase disguise = Manager.getDisguiseManager().getDisguise(ent.getEntity());
if (disguise instanceof DisguiseSheep)
{
DisguiseSheep sheep = (DisguiseSheep) disguise;
if (sheep.getColor() == 6) // Pink
{
sheep.setColor(DyeColor.RED);
}
else if (sheep.getColor() == 14) // Red
{
sheep.setColor(DyeColor.MAGENTA);
}
else if (sheep.getColor() == 2) // Magenta
{
sheep.setColor(DyeColor.PINK);
}
Manager.getDisguiseManager().updateDisguise(sheep);
}
}
}
}
}

View File

@ -11,25 +11,12 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityCombustEvent;
@ -236,7 +223,7 @@ public class NpcManager extends MiniPlugin
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
if (event.getRightClicked() instanceof LivingEntity)
@ -350,6 +337,8 @@ public class NpcManager extends MiniPlugin
((Skeleton) entity).setSkeletonType(Skeleton.SkeletonType.valueOf(npc.getDatabaseRecord().getEntityMeta().toUpperCase()));
if (entity instanceof Villager && npc.getDatabaseRecord().getEntityMeta() != null)
((Villager) entity).setProfession(Villager.Profession.valueOf(npc.getDatabaseRecord().getEntityMeta().toUpperCase()));
if (entity instanceof Sheep && npc.getDatabaseRecord().getEntityMeta() != null)
((Sheep) entity).setColor(DyeColor.valueOf(npc.getDatabaseRecord().getEntityMeta().toUpperCase()));
if (entity instanceof org.bukkit.entity.Creature)
((org.bukkit.entity.Creature) entity).setTarget(null);

View File

@ -99,6 +99,10 @@ public class RewardManager
maxValue *= 2;
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new TreasureShardReward(_clientManager, donationManager, 50, 100, 10, rarity));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Coal", "Coal", 50, 100,
new ItemStack(Material.COAL), rarity, 10, 0));
@ -160,6 +164,13 @@ public class RewardManager
maxValue *= 2;
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 2,
new ItemStack(Material.POTION, 1), rarity, 10, 0));
addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Cupid's Arrows", "Cupid Arrow", 1, 10,
new ItemStack(Material.BOW, 1), rarity, 10, 0));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Freeze Cannon", "Freeze Cannon", 5, 10,
new ItemStack(Material.ICE), rarity, 10, 0));
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Party Popper", "Party Popper", 5, 10,
@ -255,6 +266,10 @@ public class RewardManager
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new TreasureShardReward(_clientManager, donationManager, 100, 300, 10, rarity));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "Santa", "Santa",
SkinData.SANTA.getSkull(), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new PetReward(petManager, inventoryManager, donationManager, "Elf", "Christmas Elf",
@ -324,6 +339,17 @@ public class RewardManager
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Arrow Effect", "Arrows of Cupid", "Arrows of Cupid",
new ItemStack(Material.POTION), rarity, 10, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Death Effect", "Broken Hearted", "Broken Hearted",
new ItemStack(Material.POTION), rarity, 10, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Jump Effect", "Wings of Love", "Wings of Love",
new ItemStack(Material.POTION), rarity, 10, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Particles", "Heartfelt Halo", "Heartfelt Halo",
new ItemStack(Material.POTION), rarity, 10, _rareShards));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "The Grinch", "The Grinch",
SkinData.THE_GRINCH.getSkull(), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Morph", "Olaf", "Olaf Morph",

View File

@ -35,6 +35,7 @@ public class RewardPool
public static enum Type
{
NORMAL,
WINTER_HOLIDAY;
WINTER_HOLIDAY,
VALENTINES_GIFT;
}
}

View File

@ -11,6 +11,7 @@ public enum RewardType
AncientChest( 0, 2, 8, 32),
MythicalChest( 0.1, 4, 16, 72),
WinterChest( 0, 5, 18, 32),
ValentinesGift( 9, 10, 25, 40),
SpinnerFiller( 0.1, 1, 4, 20),
SpinnerReal( 0.000001, 0.05, 0.4, 5);

View File

@ -1,6 +1,7 @@
package mineplex.core.reward.rewards;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -18,7 +19,8 @@ public class TreasureShardReward extends Reward
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private Reward _otherReward;
private int _shards = 0;
private int _shardsMin = 0;
private int _shardsMax = 0;
public TreasureShardReward(CoreClientManager clientManager, DonationManager donationManager, Reward otherReward, int weight, RewardRarity rarity)
{
@ -28,14 +30,36 @@ public class TreasureShardReward extends Reward
_donationManager = donationManager;
_otherReward = otherReward;
_shards += (int) (otherReward.getShardValue() + (Math.random() * otherReward.getShardValue() / 2.0));
_shardsMin = (int) (otherReward.getShardValue() + (Math.random() * otherReward.getShardValue() / 2.0));
_shardsMax = _shardsMin;
}
public TreasureShardReward(CoreClientManager clientManager, DonationManager donationManager, int min, int max, int weight, RewardRarity rarity)
{
super(rarity, weight, 0);
_clientManager = clientManager;
_donationManager = donationManager;
_shardsMin = min;
_shardsMax = max;
}
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
{
RewardData fakeData = _otherReward.getFakeRewardData(player);
RewardData rewardData = new RewardData(fakeData.getHeader(), fakeData.getFriendlyName(), fakeData.getDisplayItem(), fakeData.getRarity(), _shards);
RewardData rewardData;
final int shards = UtilMath.rRange(_shardsMin, _shardsMax);
if (_otherReward != null)
{
RewardData fakeData = _otherReward.getFakeRewardData(player);
rewardData = new RewardData(fakeData.getHeader(), fakeData.getFriendlyName(), fakeData.getDisplayItem(), fakeData.getRarity(), shards);
}
else
{
rewardData = new RewardData(null, getRarity().getColor() + shards + " Treasure Shards", new ItemStack(Material.PRISMARINE_SHARD), getRarity());
}
int accountId = _clientManager.getAccountId(player);
@ -45,7 +69,7 @@ public class TreasureShardReward extends Reward
@Override
public void run()
{
_donationManager.rewardCoinsUntilSuccess(null, "Treasure", player.getName(), accountId, _shards);
_donationManager.rewardCoinsUntilSuccess(null, "Treasure", player.getName(), accountId, shards);
}
}, 100);

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -210,4 +211,13 @@ public class ShopItem extends ItemStack
return this;
}
public ShopItem hideInfo()
{
ItemMeta meta = getItemMeta();
meta.addItemFlags(ItemFlag.values());
setItemMeta(meta);
return this;
}
}

View File

@ -0,0 +1,103 @@
package mineplex.core.valentines;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.*;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.*;
import mineplex.core.valentines.event.AttemptGiftEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
public class ValentinesGiftManager extends MiniPlugin
{
private final String ITEM_NAME = "Valentines Gift";
private final Material ITEM_MATERIAL = Material.RED_ROSE;
private CoreClientManager _clientManager;
private RewardManager _rewardManager;
private InventoryManager _inventoryManager;
private GadgetManager _gadgetManager;
private ValentinesGiftRepository _repository;
public ValentinesGiftManager(JavaPlugin plugin, CoreClientManager clientManager, RewardManager rewardManager, InventoryManager inventoryManager, GadgetManager gadgetManager)
{
super("Valentines", plugin);
_clientManager = clientManager;
_rewardManager = rewardManager;
_inventoryManager = inventoryManager;
_gadgetManager = gadgetManager;
_repository = new ValentinesGiftRepository(plugin);
}
@EventHandler
public void onAttemptGift(AttemptGiftEvent event)
{
Player from = event.getFrom();
Player to = event.getTo();
final int fromId = _clientManager.getAccountId(from);
final int toId = _clientManager.getAccountId(to);
runAsync(() -> {
// final boolean complete = _repository.giveGift(fromId, toId);
final boolean complete = true;
runSync(() -> giveGift(from, to, complete));
});
}
private void giveGift(Player from, Player to, boolean success)
{
if (success)
{
_inventoryManager.addItemToInventory(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
_rewardManager.nextReward(to, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.ValentinesGift, false).giveReward(RewardType.ValentinesGift, to, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
UtilTextMiddle.display(data.getRarity().getColor() + data.getFriendlyName(), C.cPurple + "Gift from " + from.getName(), to);
UtilPlayer.message(to, F.main("Gift", F.name(from.getName()) + " gave you " + data.getRarity().getColor() + data.getFriendlyName()));
UtilPlayer.message(from, F.main("Gift", "You gave " + F.name(to.getName()) + " " + data.getRarity().getColor() + data.getFriendlyName()));
}
});
_rewardManager.nextReward(from, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.ValentinesGift, false).giveReward(RewardType.ValentinesGift, from, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
UtilTextMiddle.display(data.getRarity().getColor() + data.getFriendlyName(), C.cPurple + "Gift in Return", from);
UtilPlayer.message(from, F.main("Gift", "You found " + F.elem(data.getRarity().getColor() + data.getFriendlyName()) + " for your good karma"));
}
});
from.getInventory().setItem(_gadgetManager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(ITEM_MATERIAL, (byte) 0, 1, F.item(_inventoryManager.Get(from).getItemCount(ITEM_NAME) + " " + ITEM_NAME)));
}
else
{
UtilPlayer.message(from, F.main("Gift", "Error giving gift! Please try again"));
}
}
}, from, ITEM_NAME, -1);
}
else
{
UtilPlayer.message(from, F.main("Gift", "Spread the love! You have already gifted " + F.name(to.getName())));
}
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.valentines;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnInt;
import org.bukkit.plugin.java.JavaPlugin;
public class ValentinesGiftRepository extends RepositoryBase
{
private String GIVE_GIFT = "INSERT INTO accountValentinesGift (senderId, targetId) VALUES (?, ?);";
public ValentinesGiftRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
public boolean giveGift(int senderId, int targetId)
{
return executeUpdate(GIVE_GIFT, new ColumnInt("senderId", senderId), new ColumnInt("targetId", targetId)) == 1;
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.valentines.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class AttemptGiftEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { return handlers; }
public HandlerList getHandlers() { return handlers; }
private Player _from;
private Player _to;
public AttemptGiftEvent(Player from, Player to)
{
_from = from;
_to = to;
}
public Player getFrom()
{
return _from;
}
public Player getTo()
{
return _to;
}
}

View File

@ -8,6 +8,41 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import mineplex.core.reward.RewardManager;
import mineplex.core.valentines.ValentinesGiftManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
@ -18,7 +53,6 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.Rank;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
@ -74,7 +108,6 @@ import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.HolidayGiftManager;
import mineplex.hub.modules.HubVisibilityManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.KothManager;
@ -82,6 +115,7 @@ import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager;
import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.ValentinesManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.profile.gui.GUIProfile;
import mineplex.hub.tutorial.TutorialManager;
@ -90,51 +124,12 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.ConditionManager;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import org.jooq.tools.json.JSONObject;
import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
public class HubManager extends MiniClientPlugin<HubClient>
{
@ -168,6 +163,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private PlayerCountManager _playerCountManager;
private CustomDataManager _customDataManager;
private Punish _punishManager;
private ValentinesManager _valentinesManager;
// private HalloweenSpookinessManager _halloweenManager;
// private TrickOrTreatManager _trickOrTreatManager;
@ -221,7 +217,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
_inventoryManager = inventoryManager;
new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
@ -259,6 +255,12 @@ public class HubManager extends MiniClientPlugin<HubClient>
new PlayerDisguiseManager(plugin, _clientManager);
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
// new MailManager(_plugin, notificationManager);
new ValentinesGiftManager(plugin, clientManager, new RewardManager(clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, statsManager, giveawayManager,
100, 250,
500, 1000,
4000, 6000,
12000, 22000,
true, false), inventoryManager, _gadgetManager);
_playerCountManager = new PlayerCountManager(plugin);
@ -267,6 +269,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
_songs = new ArrayList<NoteSong>();
_punishManager = punish;
_valentinesManager = new ValentinesManager(plugin, clientManager, donationManager);
try
{

View File

@ -0,0 +1,135 @@
package mineplex.hub.modules;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
import mineplex.core.server.util.TransactionResponse;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.modules.valentines.Courtship;
public class ValentinesManager extends MiniPlugin
{
/**
* Created by: Mysticate
* Timestamp: February 6, 2016
*/
private final boolean _enabled = true;
private final String _prefix = C.cRed + "Polly the Pink Sheep";
private final String _identifier = "Polly the Pink Sheep";
private final String _reward = "Loving Sheeples"; // The sales package to reward
private final float _dropRate = .5F; // 50%
private CoreClientManager _client;
private DonationManager _donation;
private Courtship _active = null;
private long _lastEnd = -1;
public ValentinesManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation)
{
super("Valentines Sheep Manager", plugin);
_client = client;
_donation = donation;
}
@EventHandler
public void onGadget(GadgetCollideEntityEvent event)
{
if (!_enabled)
return;
if (!(event.getGadget() instanceof ItemLovePotion))
return;
if (!(event.getOther() instanceof Sheep))
return;
Player player = event.getPlayer();
player.sendMessage(event.getOther().getCustomName());
if (!event.getOther().getCustomName().contains(_identifier))
return;
if (_lastEnd != -1 && !UtilTime.elapsed(_lastEnd, 1000))
return;
if (_active != null)
{
UtilPlayer.message(player, F.main("Cupid", "Someone is already courting " + F.elem(_prefix) + "!"));
return;
}
if (_donation.Get(player).OwnsUnknownPackage(_reward))
{
UtilPlayer.message(player, F.main(_prefix, "I already love you!"));
return;
}
event.setCancelled(false); // Uncancel
final boolean success = UtilMath.random.nextFloat() > 1 - _dropRate;
_active = new Courtship(this, player, (Sheep) event.getOther(), _prefix, success);
}
@EventHandler
public void onTick(UpdateEvent event)
{
if (_active == null)
return;
if (event.getType() == UpdateType.TICK)
{
if (_active.tick())
{
_active = null;
_lastEnd = System.currentTimeMillis();
}
}
}
public void giveReward(Player player)
{
_donation.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
@Override
public void run(TransactionResponse data)
{
// if (data == TransactionResponse.AlreadyOwns)
// {
// UtilPlayer.message(player, "owned but it worked");
// }
//
if (data == TransactionResponse.AlreadyOwns || data == TransactionResponse.Failed)
{
UtilPlayer.message(player, F.main("Error", "An error occured while rewarding " + F.elem(_reward) + "."));
return;
}
if (data == TransactionResponse.Success)
{
UtilPlayer.message(player, F.main("Reward", "You recieved " + F.elem(_reward + " Mount") + " from " + F.elem(_prefix) + "!"));
}
}
}, player.getName(), _client.getAccountId(player), _reward, CurrencyType.Coins, 0, true);
}
}

View File

@ -0,0 +1,179 @@
package mineplex.hub.modules.valentines;
import org.bukkit.DyeColor;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.hub.modules.ValentinesManager;
public class Courtship
{
/**
* Created by: Mysticate
* Timestamp: February 6, 2016
*/
private ValentinesManager _manager;
private Player _player;
private Sheep _sheep;
private String _prefix;
private final boolean _success;
private int _tick = 0;
public Courtship(ValentinesManager manager, Player player, Sheep sheep, String prefix, boolean success)
{
_manager = manager;
_player = player;
_sheep = sheep;
_prefix = prefix;
_success = success;
}
public boolean tick()
{
if (!_player.isOnline())
return true;
_tick++;
{
Vector vec = UtilAlg.getTrajectory(_sheep, _player);
UtilEnt.CreatureForceLook(_sheep, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec));
}
for (Player player : UtilPlayer.getNearby(_sheep.getLocation(), 4))
{
if (player != _player)
{
if (Recharge.Instance.use(player, "Sheep Bump", 500, false, false))
{
Entity bottom = player;
while (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(_sheep, bottom), .5, true, 0.8, 0, 10, true);
player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
UtilPlayer.message(player, F.main(_prefix, "I'm talking to someone else right now!"));
}
}
}
if (_tick == 20)
{
message("What do we have here?");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, 1F, 1F);
}
if (_tick == 40)
{
if (_success)
{
message("I feel weird...");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, 2F, 1F);
}
else
{
message("Was that a love potion?");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, .5F, 1F);
}
}
if (_tick > 40 && _tick < 80)
{
if (_tick % 2 == 0)
{
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.DIG_GRASS, 1F, 1F);
UtilParticle.PlayParticle(ParticleType.HEART, _sheep.getLocation().clone().add(0, 1, 0), new Vector(), 0F, 1, ViewDist.NORMAL, _player);
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _sheep.getLocation(), 1F, 1F, 1F, 0F, 1, ViewDist.NORMAL, _player);
_sheep.setColor(DyeColor.PINK);
}
else
{
_sheep.setColor(DyeColor.WHITE);
}
}
if (_tick == 80)
{
if (_success)
{
message("I...");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.FIZZ, 1F, 1F);
}
else
{
message("I don't think of you like that. I'm sorry.");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.ANVIL_BREAK, 1F, 1F);
_sheep.setColor(DyeColor.BLACK);
}
}
if (_tick > 80 && _tick < 120 && _success)
{
if (_tick % 2 == 0)
{
_sheep.setColor(DyeColor.PINK);
}
else
{
_sheep.setColor(DyeColor.RED);
}
}
if (_tick == 90 && _success)
{
message("I think...");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.FIZZ, 1F, 1F);
}
if (_tick == 100 && _success)
{
message("I think I'm in love!");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F);
}
if (_tick == 120 && _success)
{
message("Here, take this present as a token of my admiration.");
_sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F);
_manager.giveReward(_player);
_sheep.setColor(DyeColor.RED);
UtilServer.broadcast(C.cRedB + "Cupid: " + C.cWhiteB + C.cYellowB + _player.getName() + C.cWhiteB + " tricked " + C.cGoldB + "Polly the Pink Sheep" + C.cWhiteB + " with a love potion!");
}
if (_tick == 130)
{
_sheep.setColor(DyeColor.PINK);
return true;
}
return false;
}
private void message(String message)
{
UtilPlayer.message(_player, " ");
UtilPlayer.message(_player, F.main(_prefix, message));
}
}

View File

@ -143,7 +143,7 @@ public class Arcade extends JavaPlugin
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress);
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);
cosmeticManager.setInterfaceSlot(7);
cosmeticManager.disableTeamArmor();