Merge branch 'update/aprilppc' into update/aprilchest

This commit is contained in:
LCastr0 2017-03-20 19:23:33 -03:00
commit 4cd25ad921
7 changed files with 372 additions and 13 deletions

View File

@ -7,6 +7,16 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.TileEntityFlowerPot;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
@ -35,15 +45,6 @@ import com.mojang.authlib.GameProfile;
import mineplex.core.common.Pair;
import mineplex.core.common.block.MultiBlockUpdaterAgent;
import mineplex.core.common.skin.SkinData;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.TileEntityFlowerPot;
import net.minecraft.server.v1_8_R3.WorldServer;
public class UtilBlock
{
@ -394,7 +395,17 @@ public class UtilBlock
{
return blockUseSet.contains(block);
}
public static Set<Block> getBlocksInRadius(Location loc, double radius)
{
return getInRadius(loc, radius).keySet();
}
public static Set<Block> getBlocksInRadius(Location loc, double radius, int maxHeight)
{
return getInRadius(loc, radius, maxHeight).keySet();
}
public static HashMap<Block, Double> getInRadius(Location loc, double dR)
{
return getInRadius(loc, dR, 9999);

View File

@ -164,6 +164,7 @@ import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo;
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons;
import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal;
@ -448,6 +449,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new ParticleFreedom(this));
addGadget(new ParticleChristmasTree(this));
addGadget(new ParticleWingsLove(this));
addGadget(new ParticleSpringHalo(this));
// Arrow Trails
addGadget(new ArrowTrailFrostLord(this));

View File

@ -0,0 +1,168 @@
package mineplex.core.gadget.gadgets.particle.spring;
import java.time.Month;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.RGBData;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.particleeffects.ColoredCircleEffect;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class ParticleSpringHalo extends ParticleGadget
{
private Map<Player, ColoredCircleEffect> _effects = new HashMap<>();
private List<SpringHaloData> _springHaloData = new ArrayList<>();
private Map<Player, List<SpringHaloData>> _playerSpringHaloData = new HashMap<>();
public ParticleSpringHalo(GadgetManager manager)
{
// TODO CHANGE LORE BEFORE RELEASE
super(manager, "Spring Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), -14, Material.GLASS, (byte) 0, YearMonth.of(2017, Month.APRIL));
}
@Override
public void enableCustom(Player player, boolean message)
{
super.enableCustom(player, message);
Manager.removeGadgetType(player, GadgetType.MORPH, this);
Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET);
ColoredCircleEffect circleEffect = new ColoredCircleEffect(Manager.getPlugin(), player, 0.7d, false);
RGBData colorA = UtilColor.hexToRgb(0x5a92ed);
RGBData colorB = UtilColor.hexToRgb(0xdb5aed);
RGBData colorC = UtilColor.hexToRgb(0xd2cdf2);
RGBData colorD = UtilColor.hexToRgb(0x7c6df2);
RGBData colorE = UtilColor.hexToRgb(0xedeb97);
RGBData colorF = UtilColor.hexToRgb(0xeac07c);
circleEffect.addColors(colorA, colorB, colorC, colorD, colorE, colorF);
circleEffect.setYOffset(2.3d);
circleEffect.start();
_effects.put(player, circleEffect);
player.getEquipment().setHelmet(new ItemStack(Material.RED_ROSE, 1, (byte) 8));
}
@Override
public void disableCustom(Player player, boolean message)
{
super.disableCustom(player, message);
if (_effects.containsKey(player))
{
ColoredCircleEffect circleEffect = _effects.get(player);
if (circleEffect != null)
{
circleEffect.stop();
}
}
_effects.remove(player);
player.getInventory().setHelmet(null);
if (_playerSpringHaloData.containsKey(player))
{
Iterator<SpringHaloData> iterator = _playerSpringHaloData.get(player).iterator();
while (iterator.hasNext())
{
SpringHaloData springHaloData = iterator.next();
springHaloData.getBlock().setType(Material.AIR);
springHaloData.getBlock().setData((byte) 0);
iterator.remove();
}
_playerSpringHaloData.get(player).clear();
_playerSpringHaloData.remove(player);
}
}
@Override
public void playParticle(Player player, UpdateEvent event)
{
}
@EventHandler
public void spawnFlowers(PlayerMoveEvent event)
{
if (!isActive(event.getPlayer()))
return;
Player player = event.getPlayer();
Block block = event.getFrom().getBlock();
if (block.getType() != Material.AIR)
return;
if (block.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.GRASS
&& block.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.DIRT)
return;
block.setType(Material.RED_ROSE);
block.setData((byte) UtilMath.random.nextInt(8));
SpringHaloData springHaloData = new SpringHaloData(player, block, System.currentTimeMillis());
addFlower(player, springHaloData);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<SpringHaloData> iterator = _springHaloData.iterator();
while (iterator.hasNext())
{
SpringHaloData springHaloData = iterator.next();
if (UtilTime.elapsed(springHaloData.getSpawned(), 1500))
{
springHaloData.getBlock().setType(Material.AIR);
springHaloData.getBlock().setData((byte) 0);
removeSpringHalo(springHaloData);
iterator.remove();
}
}
}
private void addFlower(Player player, SpringHaloData springHaloData)
{
_springHaloData.add(springHaloData);
if (_playerSpringHaloData.containsKey(player))
{
List<SpringHaloData> list = _playerSpringHaloData.get(player);
list.add(springHaloData);
}
else
{
List<SpringHaloData> list = new ArrayList<>();
list.add(springHaloData);
_playerSpringHaloData.put(player, list);
}
}
private void removeSpringHalo(SpringHaloData springHaloData)
{
Player player = springHaloData.getPlayer();
List<SpringHaloData> list = _playerSpringHaloData.get(player);
if (list != null)
{
list.remove(springHaloData);
}
}
}

View File

@ -0,0 +1,34 @@
package mineplex.core.gadget.gadgets.particle.spring;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class SpringHaloData
{
private Player _player;
private Block _block;
private long _spawned;
public SpringHaloData(Player player, Block block, long spawned)
{
_player = player;
_block = block;
_spawned = spawned;
}
public Player getPlayer()
{
return _player;
}
public Block getBlock()
{
return _block;
}
public long getSpawned()
{
return _spawned;
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.gadget.types;
import java.time.YearMonth;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,7 +30,12 @@ public abstract class ParticleGadget extends Gadget
public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames)
{
super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, 1, altNames);
}
}
public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth, String... altNames)
{
super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, yearMonth, 1, altNames);
}
@Override
public void enableCustom(Player player, boolean message)

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
@ -23,6 +24,7 @@ public class CircleEffect extends Effect
private List<Color> _randomColors = new ArrayList<>();
private int _maxCircles = -1;
private int _totalCircles = 0;
private double _yOffset = 0.0;
private static final double RANDOM_COLOR_CHANCE = 0.5;
private static final int PARTICLES_PER_CIRCLE = 20;
@ -40,6 +42,14 @@ public class CircleEffect extends Effect
_instantly = instantly;
}
public CircleEffect(JavaPlugin plugin, Entity entity, double radius, Color color, boolean instantly)
{
super(-1, new EffectLocation(entity), plugin);
_radius = radius;
_color = color;
_instantly = instantly;
}
public void addRandomColor(Color color)
{
_randomColors.add(color);
@ -50,6 +60,11 @@ public class CircleEffect extends Effect
_maxCircles = circles;
}
public void setYOffset(double yOffset)
{
_yOffset = yOffset;
}
@Override
public void runEffect()
{
@ -57,7 +72,7 @@ public class CircleEffect extends Effect
{
for (int i = 0; i < PARTICLES_PER_CIRCLE; i++)
{
Location location = getEffectLocation().getFixedLocation();
Location location = getEffectLocation().getLocation().add(0, _yOffset, 0);
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);
@ -86,7 +101,7 @@ public class CircleEffect extends Effect
return;
}
}
Location location = getEffectLocation().getFixedLocation();
Location location = getEffectLocation().getLocation().add(0, _yOffset, 0);
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);

View File

@ -0,0 +1,122 @@
package mineplex.core.particleeffects;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.RGBData;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
public class ColoredCircleEffect extends Effect
{
private double _radius;
private List<Color> _colors;
private int _steps = 0;
private boolean _instantly = true;
private int _maxCircles = -1;
private int _totalCircles = 0;
private double _yOffset = 0.0;
private static final int PARTICLES_PER_CIRCLE = 20;
public ColoredCircleEffect(JavaPlugin plugin, Entity entity, double radius, boolean instantly, Color... colors)
{
super(-1, new EffectLocation(entity), plugin);
_radius = radius;
_colors = new ArrayList<>();
_instantly = instantly;
Collections.addAll(_colors, colors);
}
public void setMaxCircles(int circles)
{
_maxCircles = circles;
}
public void setYOffset(double yOffset)
{
_yOffset = yOffset;
}
public void addColor(Color color)
{
_colors.add(color);
}
public void addColors(Color... colors)
{
Collections.addAll(_colors, colors);
}
public void addColor(RGBData rgbData)
{
_colors.add(new Color(rgbData.getFullRed(), rgbData.getFullGreen(), rgbData.getFullBlue()));
}
public void addColors(RGBData... rgbDatas)
{
for (RGBData rgbData : rgbDatas)
{
addColor(rgbData);
}
}
@Override
public void runEffect()
{
if (_instantly)
{
for (int i = 0; i < PARTICLES_PER_CIRCLE; i++)
{
Location location = getEffectLocation().getLocation().add(0, _yOffset, 0);
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector));
coloredParticle.display();
_steps++;
}
stop();
}
else
{
if (_maxCircles != -1)
{
if (_totalCircles >= _maxCircles)
{
stop();
return;
}
}
Location location = getEffectLocation().getLocation().add(0, _yOffset, 0);
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector));
coloredParticle.display();
_steps++;
if (_steps >= PARTICLES_PER_CIRCLE)
{
_totalCircles++;
_steps = 0;
}
}
}
private Color getNextColor()
{
int r = UtilMath.random.nextInt(_colors.size());
return _colors.get(r);
}
}