Merge remote-tracking branch 'origin/master' into mrsomeone12_SmallFixes

This commit is contained in:
xGamingDudex 2015-11-28 02:31:09 +01:00
commit 070c436677
26 changed files with 869 additions and 156 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class UtilAlg
@ -439,4 +440,9 @@ public class UtilAlg
return value;
}
public static EulerAngle vectorToEuler(Vector vector)
{
return new EulerAngle(Math.toRadians(GetPitch(vector)), Math.toRadians(GetYaw(vector)), 0);
}
}

View File

@ -624,4 +624,30 @@ public class UtilBlock
return block.getTypeId();
}
}
public static HashSet<Block> findConnectedBlocks(Block block, HashSet<Block> blocks, int limit)
{
if (blocks == null)
blocks = new HashSet<Block>();
//This is incase you recursively check an entire MC world
if (blocks.size() >= limit)
return blocks;
//Mark current node as searched
blocks.add(block);
//Search the node
for (Block neighbour : UtilBlock.getSurrounding(block, false))
{
if (neighbour.getType() == Material.AIR)
continue;
//If neighbour hasn't been searched, recursively search it!
if (!blocks.contains(neighbour))
findConnectedBlocks(neighbour, blocks, limit);
}
return blocks;
}
}

View File

@ -644,6 +644,11 @@ public class UtilEnt
return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec));
}
public static boolean CreatureLook(Entity ent, Vector target)
{
return CreatureLook(ent, UtilAlg.GetPitch(target), UtilAlg.GetYaw(target));
}
public static void setFakeHead(Entity ent, boolean fakeHead)
{
net.minecraft.server.v1_8_R3.Entity ec = ((CraftEntity) ent).getHandle();

View File

@ -0,0 +1,38 @@
package mineplex.core.disguise.disguises;
import org.bukkit.entity.*;
public class DisguiseGuardian extends DisguiseCreature
{
public DisguiseGuardian(org.bukkit.entity.Entity entity)
{
super(EntityType.GUARDIAN, entity);
DataWatcher.a(16, 0);
DataWatcher.a(17, 0);
}
public void setTarget(int target)
{
DataWatcher.watch(17, target);
}
public void setElder(boolean elder)
{
DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4));
}
public boolean isElder()
{
return (this.DataWatcher.getInt(16) & 4) != 0;
}
protected String getHurtSound()
{
if (isElder())
{
return "mob.guardian.elder.hit";
}
return "mob.guardian.hit";
}
}

View File

@ -61,7 +61,7 @@ public class ItemTNT extends ItemGadget
if (!_tnt.remove(event.getEntity()))
return;
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 10);
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 8);
for (Player player : players.keySet())
{
if (Manager.collideEvent(this, player))

View File

@ -1,35 +1,216 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
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.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphTitan extends MorphGadget
{
private HashMap<Player, ArmorStand> _targets = new HashMap<Player, ArmorStand>();
public MorphTitan(GadgetManager manager)
{
super(manager, "Titanic Morph", new String[]
super(manager, "Elder Guardian Morph", new String[]
{
C.cWhite + "Coming Soon...",
C.cWhite + "From deep withinsdngsg",
" ",
C.cRed + "Unlocked with Titan Rank",
},
-1,
Material.INK_SACK, (byte)8);
Material.PRISMARINE_SHARD, (byte)0);
}
@Override
public void EnableCustom(Player player)
{
this.ApplyArmor(player);
DisguiseGuardian disguise = new DisguiseGuardian(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguise.setCustomNameVisible(true);
disguise.setElder(true);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);
player.setFlying(false);
Entity ent = _targets.remove(player);
if (ent != null)
ent.remove();
}
@EventHandler
public void lazer(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, "Guardians Laser", 4000, true, false))
return;
DisguiseBase base = Manager.getDisguiseManager().getDisguise(player);
if (base == null || !(base instanceof DisguiseGuardian))
return;
DisguiseGuardian disguise = (DisguiseGuardian)base;
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.AIR);
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
stand.setVisible(false);
stand.setGhost(true);
stand.setGravity(false);
_targets.put(player, stand);
disguise.setTarget(stand.getEntityId());
Manager.getDisguiseManager().updateDisguise(disguise);
//Fake Head
UtilEnt.setFakeHead(player, true);
Recharge.Instance.useForce(player, GetName() + " FakeHead", 2000);
}
@EventHandler
public void lazerEnd(RechargedEvent event)
{
if (event.GetAbility().equals(GetName() + " FakeHead"))
{
UtilEnt.setFakeHead(event.GetPlayer(), false);
//Explode
ArmorStand stand = _targets.remove(event.GetPlayer());
if (stand != null)
{
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, stand.getLocation(), 3f, 3f, 3f, 0, 32, ViewDist.MAX, UtilServer.getPlayers());
HashMap<LivingEntity, Double> players = UtilEnt.getInRadius(stand.getLocation(), 12);
for (Entity ent : players.keySet())
{
if (ent instanceof Player)
if (Manager.collideEvent(this, (Player)ent))
continue;
double mult = players.get(ent);
//Knockback
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 4 * mult, false, 0, 1 + 3 * mult, 10, true);
}
//Sound
stand.getWorld().playSound(stand.getLocation(), Sound.ZOMBIE_REMEDY, 6f, 0.75f);
}
//Disguise
DisguiseBase base = Manager.getDisguiseManager().getDisguise(event.GetPlayer());
if (base == null || !(base instanceof DisguiseGuardian))
return;
DisguiseGuardian disguise = (DisguiseGuardian)base;
disguise.setTarget(0);
Manager.getDisguiseManager().updateDisguise(disguise);
}
}
@EventHandler
public void selfParticles(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : _targets.keySet())
{
Vector dir = UtilAlg.getTrajectory( player.getLocation().add(0, 1.5, 0), _targets.get(player).getLocation());
dir.multiply(8);
UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT,
player.getLocation().add(0, 1.5, 0),
(float)dir.getX(),
(float)dir.getY(),
(float)dir.getZ(),
1, 0, ViewDist.LONG, UtilServer.getPlayers());
player.playSound(player.getLocation(), Sound.FIREWORK_TWINKLE2, 2f, 2f);
}
}
@EventHandler
public void flight(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetActive())
{
if (UtilPlayer.isSpectator(player))
continue;
player.setAllowFlight(true);
player.setFlying(true);
if (UtilEnt.isGrounded(player))
UtilAction.velocity(player, new Vector(0,1,0));
}
}
@EventHandler
public void titanOwner(PlayerJoinEvent event)
{
// if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN))
// {
// Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
// }
}
}

View File

@ -2,11 +2,8 @@ package mineplex.core.hologram;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -34,7 +31,7 @@ public class Hologram
/**
* 1.7 packets uses both EntityIDs while 1.8 uses only the first.
*/
private ArrayList<Entry<Integer, Integer>> _entityIds = new ArrayList<Entry<Integer, Integer>>();
private ArrayList<Integer> _entityIds = new ArrayList<Integer>();
private Entity _followEntity;
private HologramManager _hologramManager;
private String[] _hologramText = new String[0];
@ -53,6 +50,7 @@ public class Hologram
private int _viewDistance = 70;
protected Vector relativeToEntity;
private boolean _hideBoundingBox;
private HologramInteraction _interaction;
public Hologram(HologramManager hologramManager, Location location, String... text)
{
@ -61,6 +59,18 @@ public class Hologram
setText(text);
}
public Hologram setInteraction(HologramInteraction interact)
{
_interaction = interact;
return this;
}
public HologramInteraction getInteraction()
{
return _interaction;
}
/**
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
*/
@ -151,6 +161,7 @@ public class Hologram
nearbyPlayers.add(player);
}
}
return nearbyPlayers;
}
@ -229,9 +240,7 @@ public class Hologram
for (int i = 0; i < _entityIds.size(); i++)
{
Entry<Integer, Integer> entry = _entityIds.get(i);
entityIds1_8[i] = entry.getKey();
entityIds1_8[i] = _entityIds.get(i);
}
_destroy1_8 = new PacketPlayOutEntityDestroy(entityIds1_8);
@ -247,7 +256,7 @@ public class Hologram
for (int i = _entityIds.size(); i < _hologramText.length; i++)
{
_entityIds.add(new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId()));
_entityIds.add(UtilEnt.getNewEntityId());
}
}
else
@ -261,9 +270,7 @@ public class Hologram
}
for (int textRow = 0; textRow < _hologramText.length; textRow++)
{
Entry<Integer, Integer> entityIds = this._entityIds.get(textRow);
Packet[] packets1_8 = makeSpawnPackets1_8(textRow, entityIds.getKey(), _hologramText[textRow]);
Packet[] packets1_8 = makeSpawnPackets1_8(textRow, _entityIds.get(textRow), _hologramText[textRow]);
for (int i = 0; i < packets1_8.length; i++)
{
@ -326,8 +333,7 @@ public class Hologram
public Hologram setFollowEntity(Entity entityToFollow)
{
_followEntity = entityToFollow;
relativeToEntity = entityToFollow == null ? null : this._location.clone().subtract(entityToFollow.getLocation())
.toVector();
relativeToEntity = entityToFollow == null ? null : _location.clone().subtract(entityToFollow.getLocation()).toVector();
return this;
}
@ -340,7 +346,7 @@ public class Hologram
*/
public Hologram setHologramTarget(HologramTarget newTarget)
{
this._target = newTarget;
_target = newTarget;
return this;
}
@ -405,11 +411,11 @@ public class Hologram
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
_lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D));
for (Entry<Integer, Integer> entityId : this._entityIds)
for (Integer entityId : _entityIds)
{
PacketPlayOutEntity.PacketPlayOutRelEntityMove relMove = new PacketPlayOutEntity.PacketPlayOutRelEntityMove();
relMove.a = entityId.getKey();
relMove.a = entityId;
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
@ -425,13 +431,12 @@ public class Hologram
_lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D));
for (Entry<Integer, Integer> entityId : this._entityIds)
for (Integer entityId : _entityIds)
{
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = entityId.getKey();
teleportPacket.a = entityId;
teleportPacket.b = x;
teleportPacket.c = (int) Math
.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.285)) * 32);
teleportPacket.c = (int) Math.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.285)) * 32);
teleportPacket.d = z;
packets1_8[i] = teleportPacket;
@ -458,6 +463,11 @@ public class Hologram
return this;
}
public boolean isEntityId(int entityId)
{
return _entityIds.contains(entityId);
}
/**
* Set the hologram text
*/
@ -491,28 +501,28 @@ public class Hologram
{
// Add entity id and send spawn packets
// You add a entity id because the new hologram needs
Entry<Integer, Integer> entry = new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId());
_entityIds.add(entry);
int entityId = UtilEnt.getNewEntityId();
_entityIds.add(entityId);
packets1_8.addAll(Arrays.asList(makeSpawnPackets1_8(i, entry.getKey(), newText[i])));
packets1_8.addAll(Arrays.asList(makeSpawnPackets1_8(i, entityId, newText[i])));
}
// If less lines than previously
else if (i >= newText.length)
{
// Remove entity id and send destroy packets
Entry<Integer, Integer> entry = _entityIds.remove(newText.length);
Integer entityId = _entityIds.remove(newText.length);
destroy1_8 = Arrays.copyOf(destroy1_8, destroy1_8.length + 1);
destroy1_8[destroy1_8.length - 1] = entry.getKey();
destroy1_8[destroy1_8.length - 1] = entityId;
}
else if (!newText[i].equals(_hologramText[i]))
{
// Send update metadata packets
Entry<Integer, Integer> entry = _entityIds.get(i);
Integer entityId = _entityIds.get(i);
PacketPlayOutEntityMetadata metadata1_8 = new PacketPlayOutEntityMetadata();
metadata1_8.a = entry.getKey();
metadata1_8.a = entityId;
DataWatcher watcher1_8 = new DataWatcher(null);
@ -552,7 +562,7 @@ public class Hologram
*/
public Hologram setViewDistance(int newDistance)
{
this._viewDistance = newDistance;
_viewDistance = newDistance;
return setLocation(getLocation());
}
@ -593,6 +603,7 @@ public class Hologram
_playersTracking.clear();
_lastMovement = null;
}
return this;
}

View File

@ -0,0 +1,9 @@
package mineplex.core.hologram;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public interface HologramInteraction
{
public void onClick(Player player, ClickType clickType);
}

View File

@ -5,90 +5,106 @@ import java.util.Iterator;
import java.util.List;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class HologramManager implements Listener
public class HologramManager implements Listener, IPacketHandler
{
private ArrayList<Hologram> _activeHolograms = new ArrayList<Hologram>();
private ArrayList<Hologram> _activeHolograms = new ArrayList<Hologram>();
public HologramManager(JavaPlugin arcadeManager)
{
Bukkit.getPluginManager().registerEvents(this, arcadeManager);
}
public HologramManager(JavaPlugin arcadeManager, PacketHandler packetHandler)
{
Bukkit.getPluginManager().registerEvents(this, arcadeManager);
packetHandler.addPacketHandler(this, true, PacketPlayInUseEntity.class);
}
void addHologram(Hologram hologram)
{
_activeHolograms.add(hologram);
}
void addHologram(Hologram hologram)
{
_activeHolograms.add(hologram);
}
void removeHologram(Hologram hologram)
{
_activeHolograms.remove(hologram);
}
void removeHologram(Hologram hologram)
{
_activeHolograms.remove(hologram);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onTick(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK || _activeHolograms.isEmpty())
return;
List<World> worlds = Bukkit.getWorlds();
Iterator<Hologram> itel = _activeHolograms.iterator();
while (itel.hasNext())
{
Hologram hologram = itel.next();
if (!worlds.contains(hologram.getLocation().getWorld()))
{
itel.remove();
hologram.stop();
}
else
{
if (hologram.getEntityFollowing() != null)
{
Entity following = hologram.getEntityFollowing();
if (hologram.isRemoveOnEntityDeath() && !following.isValid())
{
itel.remove();
hologram.stop();
continue;
}
if (!hologram.relativeToEntity.equals(following.getLocation().subtract(hologram.getLocation()).toVector()))
{
// And we do this so in the rare offchance it changes by a decimal. It doesn't start turning wonky.
Vector vec = hologram.relativeToEntity.clone();
hologram.setLocation(following.getLocation().add(hologram.relativeToEntity));
hologram.relativeToEntity = vec;
continue; // No need to do the rest of the code as setLocation does it.
}
}
ArrayList<Player> canSee = hologram.getNearbyPlayers();
Iterator<Player> itel2 = hologram.getPlayersTracking().iterator();
while (itel2.hasNext())
{
Player player = itel2.next();
if (!canSee.contains(player))
{
itel2.remove();
if (player.getWorld() == hologram.getLocation().getWorld())
{
UtilPlayer.sendPacket(player, hologram.getDestroyPacket());
}
}
}
for (Player player : canSee)
@EventHandler(priority = EventPriority.LOWEST)
public void onTick(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK || _activeHolograms.isEmpty())
return;
List<World> worlds = Bukkit.getWorlds();
Iterator<Hologram> itel = _activeHolograms.iterator();
while (itel.hasNext())
{
Hologram hologram = itel.next();
if (!worlds.contains(hologram.getLocation().getWorld()))
{
itel.remove();
hologram.stop();
}
else
{
if (hologram.getEntityFollowing() != null)
{
Entity following = hologram.getEntityFollowing();
if (hologram.isRemoveOnEntityDeath() && !following.isValid())
{
itel.remove();
hologram.stop();
continue;
}
if (!hologram.relativeToEntity.equals(following.getLocation().subtract(hologram.getLocation()).toVector()))
{
// And we do this so in the rare offchance it changes by a decimal. It doesn't start turning wonky.
Vector vec = hologram.relativeToEntity.clone();
hologram.setLocation(following.getLocation().add(hologram.relativeToEntity));
hologram.relativeToEntity = vec;
continue; // No need to do the rest of the code as setLocation does it.
}
}
ArrayList<Player> canSee = hologram.getNearbyPlayers();
Iterator<Player> itel2 = hologram.getPlayersTracking().iterator();
while (itel2.hasNext())
{
Player player = itel2.next();
if (!canSee.contains(player))
{
itel2.remove();
if (player.getWorld() == hologram.getLocation().getWorld())
{
UtilPlayer.sendPacket(player, hologram.getDestroyPacket());
}
}
}
for (Player player : canSee)
{
if (!hologram.getPlayersTracking().contains(player))
{
@ -96,8 +112,28 @@ public class HologramManager implements Listener
UtilPlayer.sendPacket(player, hologram.getSpawnPackets());
}
}
}
}
}
}
}
}
}
@Override
public void handle(PacketInfo packetInfo)
{
PacketPlayInUseEntity packetPlayIn = (PacketPlayInUseEntity) packetInfo.getPacket();
for (Hologram hologram : _activeHolograms)
{
if (!hologram.isEntityId(packetPlayIn.a))
continue;
if (hologram.getInteraction() != null)
{
hologram.getInteraction().onClick(packetInfo.getPlayer(),
packetPlayIn.action == EnumEntityUseAction.ATTACK ? ClickType.LEFT : ClickType.RIGHT);
}
break;
}
}
}

View File

@ -54,6 +54,7 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
Manager.setActive(player, this);
EnableCustom(player);
}
public abstract void EnableCustom(Player player);
public abstract void Disable(Player player);

View File

@ -1,27 +1,126 @@
package mineplex.core.mount.types;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountTitan extends HorseMount
public class MountTitan extends Mount<MountTitanData>
{
public MountTitan(MountManager manager)
public MountTitan(MountManager manager)
{
super(manager, "Titanic Mount", new String[]
super(manager, "Molten Snake", Material.REDSTONE_BLOCK, (byte)0, new String[]
{
C.cWhite + "Coming Soon...",
C.cWhite + "From the distant ether realm,",
C.cWhite + "this prized dragon is said to",
C.cWhite + "obey only true Heroes!",
" ",
C.cRed + "Unlocked with Titan Rank",
},
Material.INK_SACK,
(byte)8,
-1,
Color.BLACK, Style.BLACK_DOTS, Variant.UNDEAD_HORSE, 0.8, null);
}, -1);
}
@Override
public void EnableCustom(Player player)
{
player.leaveVehicle();
player.eject();
//Remove other mounts
Manager.DeregisterAll(player);
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, new MountTitanData(player, GetName()));
}
@Override
public void Disable(Player player)
{
MountTitanData data = _active.remove(player);
if (data != null)
{
data.clean();
//Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));
Manager.removeActive(player);
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (MountTitanData data : _active.values())
{
data.update();
}
}
@EventHandler
public void interactMount(PlayerInteractEntityEvent event)
{
if (event.getRightClicked() == null)
return;
if (!GetActive().containsKey(event.getPlayer()))
return;
if (!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
return;
}
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
GetActive().get(event.getPlayer()).mount(event.getPlayer(), event.getRightClicked());
}
@EventHandler
public void target(EntityTargetEvent event)
{
if (!(event.getEntity() instanceof Player))
return;
if (!GetActive().containsKey(event.getTarget()))
return;
if (!GetActive().get(event.getTarget()).ownsMount((Player)event.getEntity()))
event.setCancelled(true);
}
@EventHandler
public void titanOwner(PlayerJoinEvent event)
{
// if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN))
// {
// Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
// }
}
}

View File

@ -0,0 +1,179 @@
package mineplex.core.mount.types;
import java.util.ArrayList;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseMagmaCube;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class MountTitanData
{
private String _owner;
private LivingEntity _head;
private ArrayList<ArmorStand> _nodes;
public MountTitanData(DisguiseManager disguiseManager, Player player, String name)
{
_owner = player.getName();
// Nodes
_nodes = new ArrayList<ArmorStand>();
Location loc = player.getLocation();
loc.setYaw(0);
loc.setPitch(0);
for (int i = 0; i < 30; i++)
{
ArmorStand node = player.getWorld().spawn(loc, ArmorStand.class);
node.setVisible(false);
node.setGravity(false);
node.setHelmet(new ItemStack(Material.REDSTONE_BLOCK));
_nodes.add(node);
}
// Head
_head = (LivingEntity) player.getWorld().spawnEntity(loc, EntityType.BAT);
UtilEnt.Vegetate(_head, true);
UtilEnt.silence(_head, true);
UtilEnt.setFakeHead(_head, true);
_head.setCustomName(player.getName() + "'s " + name);
((CraftLivingEntity) _head).getHandle().setMineplexInvisible(true);
DisguiseMagmaCube disguise = new DisguiseMagmaCube(_head);
disguise.SetSize(2);
disguiseManager.disguise(disguise);
}
public void mount(Player player, Entity entity)
{
if (_head.equals(entity) || _nodes.contains(entity))
_head.setPassenger(player);
}
public void update()
{
// Head
if (_head.getPassenger() != null)
{
_head.setVelocity(_head.getPassenger().getLocation().getDirection().add(new Vector(0, 0.2, 0)));
UtilEnt.CreatureLook(_head, _head.getPassenger().getLocation().getDirection());
}
else
{
Player player = Bukkit.getPlayerExact(_owner);
if (player != null)
{
Vector moving = null;
if (UtilMath.offset(player, _head) > 12)
{
moving = _head.getLocation().getDirection().normalize();
Vector vec = moving.clone().subtract(UtilAlg.getTrajectory(player, _head)).normalize();
vec.setY(-vec.getY());
moving.add(vec.multiply(0.15));
}
else
{
moving = _head.getLocation().getDirection();
moving.setX(moving.getX() + UtilMath.rr(0.1, true));
moving.setY(moving.getY() + UtilMath.rr(0.3, true));
moving.setZ(moving.getZ() + UtilMath.rr(0.1, true));
}
moving.normalize().multiply(0.5);
UtilEnt.CreatureLook(_head, moving);
_head.setVelocity(moving);
}
}
Location infront = _head.getLocation().add(0, -1.3, 0);
infront.setYaw(0);
infront.setPitch(0);
// Move
for (int i = 0; i < 30; i++)
{
ArmorStand node = _nodes.get(i);
Location loc = node.getLocation();
// Move
if (i == 0)
node.teleport(infront);
else if (UtilMath.offset(node.getLocation(), infront) > 0.5)
node.teleport(infront.add(UtilAlg.getTrajectory(infront, node.getLocation()).multiply(0.5)));
// Rotation
node.setHeadPose(UtilAlg.vectorToEuler(UtilAlg.getTrajectory(node.getLocation(), loc)));
infront = node.getLocation();
}
// Shuffle In
if (_head.getPassenger() == null)
{
for (int i = _nodes.size() - 1; i >= 0; i--)
{
ArmorStand node = _nodes.get(i);
Location loc = node.getLocation();
if (i > 0)
infront = _nodes.get(i - 1).getLocation();
else
infront = _head.getLocation().add(0, -1.3, 0);
node.teleport(infront);
node.setHeadPose(new EulerAngle(0, -UtilAlg.GetYaw(UtilAlg.getTrajectory(node.getLocation(), loc)), 0));
// node.setHeadPose(UtilAlg.vectorToEuler(UtilAlg.getTrajectory(node.getLocation(), loc)));
}
}
}
public void clean()
{
_head.remove();
for (ArmorStand stand : _nodes)
stand.remove();
}
public boolean ownsMount(Player player)
{
return _owner.equals(player.getName());
}
}

View File

@ -42,6 +42,7 @@ public class PetFactory
_pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000));
_pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000));
_pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -1));
_pets.put(EntityType.SKELETON, new Pet("Guardian", EntityType.SKELETON, -1));
}
private void CreatePetExtras()

View File

@ -14,9 +14,12 @@ import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
@ -38,8 +41,10 @@ import org.bukkit.entity.Ageable;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
@ -159,6 +164,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (!Get(p).GetPets().containsKey(EntityType.WITHER))
Get(p).GetPets().put(EntityType.WITHER, "Widder");
}
if (rank.has(Rank.TITAN))
{
// if (!Get(p).GetPets().containsKey(EntityType.SKELETON))
// Get(p).GetPets().put(EntityType.SKELETON, "Guardian");
}
}
public void AddPetOwner(Player player, EntityType entityType, Location location)
@ -175,6 +186,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
Creature pet;
//Wither Spawn
if (entityType == EntityType.WITHER)
{
_creatureModule.SetForce(true);
@ -196,6 +208,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
_creatureModule.SetForce(false);
}
//Default Spawn
else
{
pet = (Creature)_creatureModule.SpawnEntity(location, entityType);
@ -220,6 +233,20 @@ public class PetManager extends MiniClientPlugin<PetClient>
((Villager) pet).setBaby();
((Villager) pet).setAgeLock(true);
}
else if (pet instanceof Skeleton)
{
pet.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); //stop burning
UtilEnt.silence(pet, true);
DisguiseGuardian disguise = new DisguiseGuardian(pet);
if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0)
{
disguise.setName(Get(player).GetPets().get(entityType));
}
_disguiseManager.disguise(disguise);
}
_activePetOwners.put(player.getName(), pet);
_failedAttempts.put(player.getName(), 0);
@ -335,6 +362,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
xDiff = Math.abs(petSpot.getBlockX() - ownerSpot.getBlockX());
yDiff = Math.abs(petSpot.getBlockY() - ownerSpot.getBlockY());
zDiff = Math.abs(petSpot.getBlockZ() - ownerSpot.getBlockZ());
//Guardian
if (pet instanceof Skeleton && Math.random() > 0.66 && UtilEnt.isGrounded(pet))
{
UtilAction.velocity(pet, UtilAlg.getTrajectory(pet, owner), Math.random() * 0.3 + 0.3, false, 0, 0.3, 1, true);
}
if ((xDiff + yDiff + zDiff) > 4)
{

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramInteraction;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
@ -32,6 +33,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
@ -63,7 +65,20 @@ public class TreasureLocation implements Listener
_hologramManager = hologramManager;
_statusManager = statusManager;
_currentTreasure = null;
_hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold + "Open Treasure");
_hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold
+ "Open Treasure");
_hologram.setInteraction(new HologramInteraction()
{
@Override
public void onClick(Player player, ClickType clickType)
{
if (clickType == ClickType.LEFT)
return;
openShop(player);
}
});
setHoloChestVisible(true);
_shop = new TreasureShop(treasureManager, _inventoryManager, clientManager, donationManager, this);
}

View File

@ -133,7 +133,7 @@ public class Hub extends JavaPlugin implements IRelation
SkillConditionManager conditionManager = new SkillConditionManager(this);
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager);
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);

View File

@ -160,6 +160,7 @@ public class MapParser extends JavaPlugin implements Listener
player.addAttachment(plugin, "worldedit.*", hasPermission);
player.addAttachment(plugin, "voxelsniper.sniper", hasPermission);
player.addAttachment(plugin, "voxelsniper.brush.*", hasPermission);
player.addAttachment(plugin, "coloredsigns.format", hasPermission);
}
_permissionMap.put(player, hasPermission);

View File

@ -136,7 +136,7 @@ public class Arcade extends JavaPlugin
BlockRestore blockRestore = new BlockRestore(this);
ProjectileManager projectileManager = new ProjectileManager(this);
HologramManager hologramManager = new HologramManager(this);
HologramManager hologramManager = new HologramManager(this, packetHandler);
//Inventory
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);

View File

@ -1429,6 +1429,9 @@ public class MineStrike extends TeamGame
if (event.GetLog().GetLastDamager().GetReason().contains("AWP"))
amount = 100;
else if (event.GetLog().GetLastDamager().GetReason().contains("PP-Bizon"))
amount = 600;
else if (event.GetLog().GetLastDamager().GetReason().contains("Nova"))
amount = 900;
@ -1501,14 +1504,6 @@ public class MineStrike extends TeamGame
UtilParticle.PlayParticle(ParticleType.CRIT, grenadeItem.getLocation(), 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
//Expired
if (!grenadeItem.isValid() || grenadeItem.getTicksLived() > 400)
{
grenadeItem.remove();
grenadeIterator.remove();
continue;
}
//Completed
Grenade grenade = _grenadesThrown.get(grenadeItem);
if (grenade.update(this, grenadeItem))
@ -1680,11 +1675,15 @@ public class MineStrike extends TeamGame
{
for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true))
{
Block block = player.getTargetBlock((HashSet<Byte>) null, 5);
HashSet<Material> ignoreBlocks = new HashSet<Material>();
ignoreBlocks.add(Material.AIR);
ignoreBlocks.add(Material.PORTAL);
Block block = player.getTargetBlock(ignoreBlocks, 5);
if (block == null || !_bomb.isBlock(block))
continue;
if (UtilMath.offset(player.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3)
continue;
@ -1725,15 +1724,19 @@ public class MineStrike extends TeamGame
if (_bombDefuser == null)
return;
Block block = _bombDefuser.getTargetBlock((HashSet<Byte>) null, 5);
HashSet<Material> ignoreBlocks = new HashSet<Material>();
ignoreBlocks.add(Material.AIR);
ignoreBlocks.add(Material.PORTAL);
Block block = _bombDefuser.getTargetBlock(ignoreBlocks, 5);
if (!IsAlive(_bombDefuser) || block == null || !_bomb.isBlock(block) || !_bombDefuser.isOnline() || UtilMath.offset(_bombDefuser.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3)
{
_bombDefuser.setExp(0f);
_bombDefuser = null;
_bombDefuser = null;
return;
}
//Kit or Not?
float defuseRate = 0.005f;
if (UtilGear.isMat(_bombDefuser.getInventory().getItem(8), Material.SHEARS))
@ -2429,6 +2432,21 @@ public class MineStrike extends TeamGame
}
}
@EventHandler
public void gunUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Gun gun : _gunsEquipped.keySet())
{
gun.displayAmmo(_gunsEquipped.get(gun));
}
}
@EventHandler
public void smokeUpdate(UpdateEvent event)
{
@ -2443,9 +2461,15 @@ public class MineStrike extends TeamGame
if (System.currentTimeMillis() > _smokeBlocks.get(block))
{
block.setTypeIdAndData(0, (byte)0, false);
if (block.getType() == Material.PORTAL)
block.setTypeIdAndData(0, (byte)0, false);
smokeIterator.remove();
}
else if (block.getType() == Material.AIR)
{
block.setTypeIdAndData(90, (byte)UtilMath.r(2), false);
}
}
}

View File

@ -34,10 +34,18 @@ public class Bomb
Block = planter.getLocation().getBlock();
Type = Block.getType();
Data = Block.getData();
if (Block.getType() != Material.PORTAL)
{
Type = Block.getType();
Data = Block.getData();
}
else
{
Type = Material.AIR;
Data = 0;
}
Block.setType(Material.DAYLIGHT_DETECTOR);
Block.setTypeIdAndData(Material.DAYLIGHT_DETECTOR.getId(), (byte)0, false);
StartTime = System.currentTimeMillis();
}
@ -45,7 +53,7 @@ public class Bomb
public boolean update()
{
if (Block.getType() != Material.DAYLIGHT_DETECTOR)
Block.setType(Material.DAYLIGHT_DETECTOR);
Block.setTypeIdAndData(Material.DAYLIGHT_DETECTOR.getId(), (byte)0, false);
double scale = (double)(System.currentTimeMillis() - StartTime)/(double)BombTime;

View File

@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.minestrike.Radio;
@ -34,7 +35,7 @@ public class FlashBang extends Grenade
@Override
public boolean updateCustom(MineStrike game, Entity ent)
{
if (ent.getTicksLived() > 40)
if (UtilTime.elapsed(_throwTime, 2000))
{
FireworkEffect effect = FireworkEffect.builder().flicker(true).withColor(Color.WHITE).with(Type.BALL_LARGE).trail(false).build();
UtilFirework.playFirework(ent.getLocation().add(0, 0.5, 0), effect);
@ -46,7 +47,7 @@ public class FlashBang extends Grenade
continue;
//Line of Sight
Location loc = player.getEyeLocation();
Location loc = player.getEyeLocation();
boolean sight = true;
while (UtilMath.offset(loc, ent.getLocation()) > 0.5)

View File

@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
@ -75,6 +76,8 @@ public abstract class Grenade extends StrikeItem
protected int _limit;
protected long _throwTime = 0;
public Grenade(String name, String[] desc, int cost, int gemCost, Material skin, int limit)
{
super(StrikeItemType.GRENADE, name, desc, cost, gemCost, skin);
@ -154,14 +157,19 @@ public abstract class Grenade extends StrikeItem
//Sound
playSound(game, player);
_throwTime = System.currentTimeMillis();
}
public boolean update(MineStrike game, Entity ent)
{
//Invalid
if (!ent.isValid())
if (UtilTime.elapsed(_throwTime, 20000))
return true;
//Invalid (Burned)
if (!ent.isValid())
return updateCustom(game, ent);
//Rebound Off Blocks
rebound(ent);
@ -174,7 +182,7 @@ public abstract class Grenade extends StrikeItem
public void rebound(Entity ent)
{
if (UtilEnt.isGrounded(ent) || ent.getVelocity().length() < 0.1 || ent.getTicksLived() < 4)
if (UtilEnt.isGrounded(ent) || ent.getVelocity().length() < 0.1 || !UtilTime.elapsed(_throwTime, 200))
return;
if (Math.abs(_vel.getX()) < 0.1 && Math.abs(_vel.getX()) < 0.1)

View File

@ -6,6 +6,7 @@ import java.util.List;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
@ -35,7 +36,7 @@ public class HighExplosive extends Grenade
@Override
public boolean updateCustom(MineStrike game, Entity ent)
{
if (ent.getTicksLived() > 40)
if (UtilTime.elapsed(_throwTime, 2000))
{
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION,
ent.getLocation(), 0, 0, 0, 0, 1,

View File

@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.GameTeam;
@ -37,7 +38,7 @@ public class Smoke extends Grenade
@Override
public boolean updateCustom(final MineStrike game, Entity ent)
{
if (ent.getTicksLived() > 40 && UtilEnt.isGrounded(ent))
if (UtilTime.elapsed(_throwTime, 2000) && (UtilEnt.isGrounded(ent) || !ent.isValid()))
{
// UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0.3f, 0.3f, 0.3f, 0, 1,
// ViewDist.MAX, UtilServer.getPlayers());
@ -55,7 +56,7 @@ public class Smoke extends Grenade
final int round = game.getRound();
for (final Block block : blocks.keySet())
{
if (block.getType() != Material.AIR)
if (block.getType() != Material.AIR && block.getType() != Material.PORTAL && block.getType() != Material.FIRE)
continue;
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.getPlugin(), new Runnable()
@ -84,7 +85,7 @@ public class Smoke extends Grenade
}
//18 seconds
return ent.getTicksLived() > 360;
return UtilTime.elapsed(_throwTime, 18000);
}
@Override

View File

@ -47,6 +47,8 @@ public class Gun extends StrikeItem
protected long _lastMoveTime;
protected boolean _reloading = false;
protected boolean _reloadTick = false;
public Gun(GunStats gunStats)
{
@ -124,17 +126,25 @@ public class Gun extends StrikeItem
//Use Ammo
_loadedAmmo--;
updateWeaponName(player);
//updateWeaponName(player);
//Effect
soundFire(player.getLocation());
//Visual
//Smoke
Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.2));
loc.add(UtilAlg.getRight(player.getLocation().getDirection()).multiply(0.5));
loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.3));
UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1,
loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.4));
UtilParticle.PlayParticle(Math.random() > 0.5 ? ParticleType.ANGRY_VILLAGER : ParticleType.HEART, loc, 0, 0, 0, 0, 1,
ViewDist.LONG, UtilServer.getPlayers());
//Shell
loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(0.6));
loc.add(UtilAlg.getRight(player.getLocation().getDirection()).multiply(0.7));
loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.5));
UtilParticle.PlayParticle(ParticleType.SPLASH, loc, 0, 0, 0, 0, 1,
ViewDist.LONG, UtilServer.getPlayers());
game.registerBullet(fireBullet(player, game));
@ -265,7 +275,7 @@ public class Gun extends StrikeItem
}
//Recharge
Recharge.Instance.use(player, getName() + " Reload", getReloadTime(), false, true, true);
Recharge.Instance.use(player, getName() + " Reload", getReloadTime(), false, true);
//Sound
soundReload(player.getLocation());
@ -284,17 +294,36 @@ public class Gun extends StrikeItem
{
updateWeaponName(null);
}
public void displayAmmo(Player player)
{
if (!UtilGear.isMat(player.getItemInHand(), getStack().getType()))
return;
//Weapon Bob during reload
if (_reloading)
updateWeaponName(player);
if (!Recharge.Instance.usable(player, getName() + " Reload"))
return;
if (_loadedAmmo > 0 || _reserveAmmo > 0)
UtilTextBottom.display(C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo, player);
else
UtilTextBottom.display(C.cRed + "No Ammo", player);
}
public void updateWeaponName(Player player)
{
ItemMeta meta = getStack().getItemMeta();
meta.setDisplayName(ChatColor.RESET + (getOwnerName() == null ? "" : getOwnerName() + "'s ") + C.Bold + getName() + ChatColor.RESET + " " + C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo);
meta.setDisplayName(ChatColor.RESET + (getOwnerName() == null ? "" : getOwnerName() + "'s ") + C.Bold + getName() + (_reloadTick ? ChatColor.RED : ChatColor.WHITE));
getStack().setItemMeta(meta);
getStack().setAmount(Math.max(1, _loadedAmmo));
if (player != null)
{
player.getInventory().setItem(_slot, getStack());
_reloadTick = !_reloadTick;
}
}
public double getDropOff()
@ -349,7 +378,7 @@ public class Gun extends StrikeItem
_reserveAmmo = Math.max(0, ammo - _gunStats.getClipSize());
//Update
updateWeaponName(player);
//updateWeaponName(player);
//Sound
player.getWorld().playSound(player.getEyeLocation(), Sound.PISTON_EXTEND, 1f, 1.6f);
@ -417,7 +446,7 @@ public class Gun extends StrikeItem
_loadedAmmo = _gunStats.getClipSize();
_reserveAmmo = _gunStats.getClipReserve() * _gunStats.getClipSize();
updateWeaponName(player);
//updateWeaponName(player);
}
public double getDamage()

View File

@ -43,7 +43,7 @@ public class Shotgun extends Gun
//Use Ammo
_loadedAmmo--;
updateWeaponName(player);
//updateWeaponName(false);
//Effect
soundFire(player.getLocation());