Added love potion and hub sheep thing.

This commit is contained in:
Mysticate 2016-02-07 10:19:40 -05:00
parent c1393697f8
commit a8ff714ee4
8 changed files with 354 additions and 116 deletions

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;
@ -185,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;
@ -211,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
{
@ -220,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
@ -236,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());
}
}
@ -262,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
@ -285,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

@ -59,6 +59,7 @@ import mineplex.core.gadget.gadgets.item.ItemEtherealPearl;
import mineplex.core.gadget.gadgets.item.ItemFirework;
import mineplex.core.gadget.gadgets.item.ItemFleshHook;
import mineplex.core.gadget.gadgets.item.ItemFreezeCannon;
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
import mineplex.core.gadget.gadgets.item.ItemMelonLauncher;
import mineplex.core.gadget.gadgets.item.ItemPaintballGun;
import mineplex.core.gadget.gadgets.item.ItemPaintbrush;
@ -208,6 +209,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new ItemFreezeCannon(this));
addGadget(new ItemSnowball(this));
addGadget(new ItemBow(this));
addGadget(new ItemLovePotion(this));
// Costume
addGadget(new OutfitRaveSuitHelmet(this));

View File

@ -3,12 +3,9 @@ package mineplex.core.gadget.gadgets.item;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
@ -34,7 +31,6 @@ 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.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
public class ItemBow extends ItemGadget
@ -94,7 +90,7 @@ public class ItemBow extends ItemGadget
{
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),
-6, 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));
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);
}
@ -185,15 +181,14 @@ public class ItemBow extends ItemGadget
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, 40, 1, true, false));
((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, arrow.getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER);
UtilParticle.PlayParticleToAll(ParticleType.HEART, event.getEntity().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);
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);

View File

@ -1,5 +1,9 @@
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;
@ -7,8 +11,10 @@ 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.event.player.PlayerItemConsumeEvent;
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;
@ -20,8 +26,9 @@ 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.ItemStackFactory;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
public class ItemLovePotion extends ItemGadget
@ -36,7 +43,7 @@ public class ItemLovePotion extends ItemGadget
super(
manager,
"Love Potion",
UtilText.splitLineToArray("It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE),
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,
@ -47,28 +54,49 @@ public class ItemLovePotion extends ItemGadget
"Love Potion",
Material.POTION,
(byte) 8233,
UtilText.splitLineToArray("It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE),
UtilText.splitLineToArray(C.cGray + "It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE),
1,
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(), this.GetDisplayMaterial()))
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);
@ -88,21 +116,25 @@ public class ItemLovePotion extends ItemGadget
Bukkit.getPluginManager().callEvent(gadgetEvent);
if (event.isCancelled())
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(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
ActivateCustom(event.getPlayer());
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 onConsume(PlayerItemConsumeEvent event)
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;
@ -110,49 +142,42 @@ public class ItemLovePotion extends ItemGadget
if (!IsActive(player))
return;
event.setCancelled(true);
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
UtilInv.Update(player);
}
}, 1);
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);
Bukkit.getServer().getPluginManager().callEvent(ammoEvent);
return;
}
//Recharge
if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"))
return;
{
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(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
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());
}
@EventHandler
public void Activate(PlayerInteractEvent event)
{
}
@Override
public void ActivateCustom(Player player)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 40, false, false));
}
}

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

@ -8,6 +8,39 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
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 +51,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 +106,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 +113,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 +122,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 +161,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;
@ -267,6 +261,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
_songs = new ArrayList<NoteSong>();
_punishManager = punish;
_valentinesManager = new ValentinesManager(plugin, clientManager, donationManager);
try
{

View File

@ -1,6 +1,5 @@
package mineplex.hub.modules;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
@ -14,10 +13,14 @@ 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
{
@ -29,7 +32,7 @@ public class ValentinesManager extends MiniPlugin
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 _identifier = "Polly the Pink Sheep";
private final String _reward = "Loving Sheeples"; // The sales package to reward
private final float _dropRate = .5F; // 50%
@ -37,7 +40,8 @@ public class ValentinesManager extends MiniPlugin
private CoreClientManager _client;
private DonationManager _donation;
private boolean _open = true;
private Courtship _active = null;
private long _lastEnd = -1;
public ValentinesManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation)
{
@ -49,7 +53,7 @@ public class ValentinesManager extends MiniPlugin
@EventHandler
public void onGadget(GadgetCollideEntityEvent event)
{
{
if (!_enabled)
return;
@ -61,43 +65,71 @@ public class ValentinesManager extends MiniPlugin
Player player = event.getPlayer();
String name = ChatColor.stripColor(event.getOther().getCustomName()).toLowerCase();
if (!name.contains(_identifier))
player.sendMessage(event.getOther().getCustomName());
if (!event.getOther().getCustomName().contains(_identifier))
return;
event.setCancelled(false); // Uncancel
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, "You already tricked me once!"));
UtilPlayer.message(player, F.main(_prefix, "I already love you!"));
return;
}
float random = UtilMath.random.nextFloat();
if (random < 1 - _dropRate)
{
UtilPlayer.message(player, F.main(_prefix, "I don't think of you like that, sorry."));
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();
}
}
UtilPlayer.message(player, F.main(_prefix, "I think I'm in love! Here, take one of my children as my gift to you!"));
}
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(event.getPlayer()), _reward, CurrencyType.Coins, 0, true);
}, 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));
}
}