More Cosmetics!!

This commit is contained in:
Sam 2017-11-21 19:58:48 +00:00 committed by Alexander Meech
parent 17af56f8c2
commit fc913d94a4
8 changed files with 356 additions and 42 deletions

View File

@ -13,7 +13,6 @@ import java.util.Objects;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagLong;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -22,14 +21,12 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.structs.ItemContainer;
public class UtilItem
{
public static Map<Material, EnumSet<ItemCategory>> _materials = new HashMap<>();
private static Map<Material, EnumSet<ItemCategory>> _materials = new HashMap<>();
static
{
@ -1170,25 +1167,28 @@ public class UtilItem
/**
*
* @param item The item stack to use as source for this Item entity
* @param loc Location of where to spawn the Item entity
* @param dropNaturaly If false then no velocity is applied. If true then it drops with random velocity like from when blocks break.
* @param dropNaturally If false then no velocity is applied. If true then it drops with random velocity like from when blocks break.
* @param allowPickup If false then it will disable pickup of this item.
* @param ticksToLive Ticks before this item should be removed from the ground. (default 6000 ticks = 5min, -1 to never remove it)
* @param allowMerge If false then the item will not merge with any other items.
* @return
* @return The entity spawned
*/
public static Item dropItem(ItemStack item, Location loc, boolean dropNaturaly, boolean allowPickup, int ticksToLive, boolean allowMerge)
public static Item dropItem(ItemStack item, Location loc, boolean dropNaturally, boolean allowPickup, int ticksToLive, boolean allowMerge)
{
Item ent;
if(dropNaturaly)
if (dropNaturally)
{
ent = loc.getWorld().dropItemNaturally(loc, item);
} else {
}
else
{
ent = loc.getWorld().dropItem(loc, item);
}
if(!allowPickup)
{
ent.setPickupDelay(32767);
@ -1200,17 +1200,7 @@ public class UtilItem
if(ticksToLive != -1)
{
Plugin plugin = Bukkit.getPluginManager().getPlugin("Hub");
if(plugin == null) plugin = Bukkit.getPluginManager().getPlugin("Arcade");
if(plugin == null) plugin = Bukkit.getPluginManager().getPlugins()[0];
new BukkitRunnable()
{
public void run()
{
ent.remove();
}
}.runTaskLater(plugin, ticksToLive);
UtilServer.runSyncLater(ent::remove, ticksToLive);
}
if(!allowMerge)

View File

@ -152,6 +152,7 @@ import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphDinnerbone;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter;
import mineplex.core.gadget.gadgets.morph.MorphFrostGolem;
import mineplex.core.gadget.gadgets.morph.MorphGhast;
import mineplex.core.gadget.gadgets.morph.MorphGoldPot;
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
@ -257,6 +258,7 @@ import mineplex.core.gadget.gadgets.particle.king.ParticleKing;
import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo;
import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt;
import mineplex.core.gadget.gadgets.taunts.EternalTaunt;
import mineplex.core.gadget.gadgets.taunts.FrostBreathTaunt;
import mineplex.core.gadget.gadgets.taunts.InfernalTaunt;
import mineplex.core.gadget.gadgets.taunts.RainbowTaunt;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
@ -587,6 +589,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphBiff(this));
addGadget(new MorphIvy(this));
addGadget(new MorphGhast(this));
addGadget(new MorphFrostGolem(this));
// Mounts
addGadget(new MountUndead(this));
@ -754,6 +757,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new BlowAKissTaunt(this));
addGadget(new RainbowTaunt(this));
addGadget(new InfernalTaunt(this));
addGadget(new FrostBreathTaunt(this));
// Flags
addGadget(new FlagGadget(this, FlagType.CANADA));

View File

@ -0,0 +1,153 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseIronGolem;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.gadget.util.CostConstants;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphFrostGolem extends MorphGadget
{
private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.SNOW_BLOCK)
.setTitle(C.cGreenB + "Snow Day")
.addLore("Click to create an area of snow.")
.build();
private static final ItemStack SKULL_ITEM = new ItemBuilder(Material.SKULL_ITEM, (byte) 3)
.setPlayerHead("MHF_Golem")
.build();
private static final int ACTIVE_SLOT = 2;
private static final int RADIUS = 3;
private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(30);
private static final long DURATION = TimeUnit.SECONDS.toMillis(10);
private static final Vector UP = new Vector(0, 1, 0);
private final Map<Location, Long> _ability;
public MorphFrostGolem(GadgetManager manager)
{
super(manager, "Frost Golem Morph", UtilText.splitLinesToArray(new String[] {
C.cGray + "TODO"
}, LineFormat.LORE), CostConstants.FOUND_IN_GINGERBREAD_CHESTS, Material.GLASS, (byte) 0);
_ability = new HashMap<>();
setDisplayItem(SKULL_ITEM);
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
DisguiseIronGolem disguise = new DisguiseIronGolem(player);
UtilMorph.disguise(player, disguise, Manager);
player.getInventory().setItem(ACTIVE_SLOT, ACTIVE_ITEM);
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setItem(ACTIVE_SLOT, null);
}
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
{
return;
}
Player player = event.getPlayer();
ItemStack itemStack = event.getItem();
if (!isActive(player) || itemStack == null || !itemStack.equals(ACTIVE_ITEM))
{
return;
}
event.setCancelled(true);
if (!Recharge.Instance.use(player, "Snow Day", COOLDOWN, true, true, "Cosmetics"))
{
return;
}
Location location = player.getLocation();
UtilAction.velocity(player, UP);
_ability.put(location.clone().add(0, 4, 0), System.currentTimeMillis());
UtilBlock.getInRadius(location, RADIUS).forEach((block, scale) ->
{
if (block.getType() != Material.AIR || block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
{
return;
}
byte height = (byte) (UtilMath.r(3) + 1);
Manager.getBlockRestore().snow(block, height, height, (int) (DURATION * (1 + scale)), 250, 0);
if (Math.random() < 0.1)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.SNOW_BLOCK);
}
});
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
_ability.keySet().removeIf(location ->
{
if (UtilTime.elapsed(_ability.get(location), DURATION))
{
return true;
}
UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, location, RADIUS, 0.5F, RADIUS, 0, 4, ViewDist.NORMAL);
return false;
});
}
}

View File

@ -10,10 +10,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import mineplex.core.common.Pair;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -21,9 +19,9 @@ import mineplex.core.updater.event.UpdateEvent;
public class OutfitReindeerAntlers extends OutfitReindeer
{
private static final ItemStack IN_HAND = new ItemStack(Material.DEAD_BUSH);
private static final EulerAngle LEFT_POS = new EulerAngle(Math.PI / 2D, 0, -Math.PI / 4D);
private static final EulerAngle RIGHT_POS = new EulerAngle(-LEFT_POS.getX(), 0, Math.PI - (LEFT_POS.getZ()));
private static final ItemStack HELMET = new ItemStack(Material.DEAD_BUSH);
private static final EulerAngle LEFT_POS = new EulerAngle(0, 0, -Math.PI / 4D);
private static final EulerAngle RIGHT_POS = new EulerAngle(0, 0, -LEFT_POS.getZ());
private final Map<Player, Pair<ArmorStand, ArmorStand>> _antlers;
@ -44,8 +42,8 @@ public class OutfitReindeerAntlers extends OutfitReindeer
ArmorStand left = spawnStand(player);
ArmorStand right = spawnStand(player);
left.setRightArmPose(LEFT_POS);
right.setRightArmPose(RIGHT_POS);
left.setHeadPose(LEFT_POS);
right.setHeadPose(RIGHT_POS);
_antlers.put(player, Pair.create(left, right));
updateRotation(player, left, right);
@ -71,20 +69,19 @@ public class OutfitReindeerAntlers extends OutfitReindeer
stand.setGravity(false);
stand.setVisible(false);
stand.setItemInHand(IN_HAND);
stand.getEquipment().setHelmet(HELMET);
return stand;
}
private void updateRotation(Player player, ArmorStand left, ArmorStand right)
{
Location location = player.getLocation().add(0, player.isSneaking() ? 0.3 : 0.6, 0);
Location location = player.getLocation().subtract(0, player.isSneaking() ? 0.3 : 0, 0);
location.setPitch(0);
Vector direction = location.getDirection();
location.add(location.getDirection().multiply(0.4));
left.teleport(location.clone().add(direction.add(UtilAlg.getLeft(direction)).multiply(0.4)));
direction.normalize();
right.teleport(location.clone().add(direction.multiply(-0.4)));
left.teleport(location);
right.teleport(location);
}
@EventHandler

View File

@ -0,0 +1,108 @@
package mineplex.core.gadget.gadgets.taunts;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilItem;
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.types.TauntGadget;
import mineplex.core.gadget.util.CostConstants;
import mineplex.core.particleeffects.SpiralEffect;
import mineplex.core.recharge.Recharge;
public class FrostBreathTaunt extends TauntGadget
{
private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(3);
private static final int TICKS = 80;
private static final double MAX_RADIUS = 1.3;
private static final ItemStack[] TO_DROP =
{
new ItemStack(Material.ICE),
new ItemStack(Material.SNOW_BALL),
new ItemStack(Material.PACKED_ICE)
};
public FrostBreathTaunt(GadgetManager manager)
{
super(manager, "Frost Breath Taunt",
UtilText.splitLineToArray(C.cGray + "TODO", LineFormat.LORE),
CostConstants.FOUND_IN_GINGERBREAD_CHESTS, Material.PACKED_ICE, (byte) 0);
}
@Override
public boolean onStart(Player player)
{
if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics"))
{
return false;
}
Player other = UtilPlayer.getPlayerInSight(player, 64, true);
if (other != null)
{
Bukkit.broadcastMessage(F.main(Manager.getName(), F.name(other.getName()) + " felt shivers down their spine."));
}
Location location = player.getLocation().add(0, 1.5, 0);
location.add(location.getDirection());
location.getWorld().playSound(location, Sound.ENDERDRAGON_GROWL, 1, 1);
new SpiralEffect(TICKS, MAX_RADIUS, location)
{
@Override
public void playParticle(Location location)
{
UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, location, null, 0, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, location, null, 0, 1, ViewDist.NORMAL);
if (Math.random() < 0.2)
{
UtilItem.dropItem(UtilMath.randomElement(TO_DROP), location, true, false, 10, false);
}
}
}.start();
return true;
}
@Override
public void onPlay(Player player)
{
}
@Override
public void onFinish(Player player)
{
}
@EventHandler
public void debugCommand(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/fb"))
{
onStart(event.getPlayer());
}
}
}

View File

@ -59,9 +59,7 @@ public abstract class Effect
private void update()
{
_ticks++;
if (_ticks == _ticksToRun)
if (++_ticks == _ticksToRun)
{
_task.cancel();
}

View File

@ -0,0 +1,65 @@
package mineplex.core.particleeffects;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
public abstract class SpiralEffect extends Effect
{
private static final double DELTA_THETA = Math.PI / 20D;
private static final double DELTA_Z = 0.1;
private static final double DELTA_RADIUS = 0.05;
private final double _maxRadius;
private double _radius;
private double _theta;
private double _z;
public SpiralEffect(int ticks, double maxRadius, Location location)
{
super(ticks, new EffectLocation(location));
_maxRadius = maxRadius;
}
@Override
public void runEffect()
{
double x = _radius * Math.cos(_theta);
double y = _radius * Math.sin(_theta);
double z = _z += DELTA_Z;
Location location = getEffectLocation().getFixedLocation();
location.add(x, y, z);
rotateDirection(location);
location.subtract(x * 2, y * 2, 0);
rotateDirection(location);
_theta += DELTA_THETA;
if (_radius < _maxRadius)
{
_radius += DELTA_RADIUS;
}
}
private void rotateDirection(Location location)
{
Location fixedLocation = getEffectLocation().getFixedLocation();
Vector vector = location.toVector().subtract(fixedLocation.toVector());
UtilAlg.rotateAroundXAxis(vector, Math.toRadians(location.getPitch()));
UtilAlg.rotateAroundYAxis(vector, Math.toRadians(location.getYaw()));
playParticle(fixedLocation.add(vector));
}
public abstract void playParticle(Location location);
}

View File

@ -76,17 +76,16 @@ public class GingerbreadChestAnimation extends TreasureOpenAnimation
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, getTreasureLocation().getChest())));
stand.teleport(location);
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location.add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0.01F, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location.clone().add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0.01F, 1, ViewDist.NORMAL);
for (Location chest : getTreasureLocation().getChestLocations())
{
chest = chest.clone();
if (UtilMath.offsetSquared(chest, location) < 1 && _chests.add(chest))
if (UtilMath.offset2dSquared(chest, location) < 1 && _chests.add(chest))
{
chest = chest.clone();
chest.setYaw(location.getYaw());
UtilFirework.playFirework(chest.add(0, 1, 0), FIREWORK_EFFECT);
createChestAt(chest, Material.ENDER_CHEST);
UtilFirework.playFirework(chest.add(0, 1, 0), FIREWORK_EFFECT);
}
}