More changes!
This commit is contained in:
parent
a800fee08c
commit
044927252c
@ -1,13 +1,7 @@
|
||||
package mineplex.core.itemstack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -21,10 +15,18 @@ import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.FireworkEffectMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBuilder
|
||||
{
|
||||
@ -53,14 +55,15 @@ public class ItemBuilder
|
||||
private Color _color;
|
||||
private short _data;
|
||||
private short _durability;
|
||||
private final HashMap<Enchantment, Integer> _enchants = new HashMap<Enchantment, Integer>();
|
||||
private final List<String> _lore = new ArrayList<String>();
|
||||
private final Map<Enchantment, Integer> _enchants = new HashMap<>();
|
||||
private final List<String> _lore = new ArrayList<>();
|
||||
private Material _mat;
|
||||
private String _title = null;
|
||||
private boolean _unbreakable;
|
||||
private boolean _glow;
|
||||
private String _playerHeadName = null;
|
||||
private HashSet<ItemFlag> _itemFlags = new HashSet<ItemFlag>();
|
||||
private Set<ItemFlag> _itemFlags = new HashSet<>();
|
||||
private List<PotionEffect> _potionEffects = new ArrayList<>();
|
||||
|
||||
public ItemBuilder(ItemStack item)
|
||||
{
|
||||
@ -86,6 +89,13 @@ public class ItemBuilder
|
||||
{
|
||||
setColor(((LeatherArmorMeta) meta).getColor());
|
||||
}
|
||||
else if (meta instanceof PotionMeta)
|
||||
{
|
||||
for (PotionEffect effect : ((PotionMeta) meta).getCustomEffects())
|
||||
{
|
||||
addPotionEffect(effect);
|
||||
}
|
||||
}
|
||||
|
||||
_itemFlags.addAll(meta.getItemFlags());
|
||||
|
||||
@ -124,7 +134,7 @@ public class ItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public HashSet<ItemFlag> getItemFlags()
|
||||
public Set<ItemFlag> getItemFlags()
|
||||
{
|
||||
return _itemFlags;
|
||||
}
|
||||
@ -279,6 +289,22 @@ public class ItemBuilder
|
||||
{
|
||||
((BannerMeta) meta).setBaseColor(DyeColor.getByColor(_color));
|
||||
}
|
||||
else if (meta instanceof PotionMeta)
|
||||
{
|
||||
PotionMeta potionMeta = (PotionMeta) meta;
|
||||
|
||||
for (PotionEffect effect : _potionEffects)
|
||||
{
|
||||
potionMeta.addCustomEffect(effect, true);
|
||||
}
|
||||
|
||||
if (!_potionEffects.isEmpty())
|
||||
{
|
||||
potionMeta.setMainEffect(_potionEffects.get(0).getType());
|
||||
}
|
||||
|
||||
meta = potionMeta;
|
||||
}
|
||||
|
||||
meta.addItemFlags(getItemFlags().toArray(new ItemFlag[0]));
|
||||
meta.spigot().setUnbreakable(isUnbreakable());
|
||||
@ -307,7 +333,7 @@ public class ItemBuilder
|
||||
}
|
||||
|
||||
newBuilder.setColor(_color);
|
||||
// newBuilder.potion = potion;
|
||||
|
||||
newBuilder.setDurability(_durability);
|
||||
|
||||
newBuilder.setData(_data);
|
||||
@ -321,11 +347,16 @@ public class ItemBuilder
|
||||
newBuilder.setItemFlags(_itemFlags);
|
||||
|
||||
newBuilder.setPlayerHead(_playerHeadName);
|
||||
|
||||
for (PotionEffect potionEffect : _potionEffects)
|
||||
{
|
||||
newBuilder.addPotionEffect(potionEffect);
|
||||
}
|
||||
|
||||
return newBuilder;
|
||||
}
|
||||
|
||||
public HashMap<Enchantment, Integer> getAllEnchantments()
|
||||
public Map<Enchantment, Integer> getAllEnchantments()
|
||||
{
|
||||
return _enchants;
|
||||
}
|
||||
@ -452,4 +483,9 @@ public class ItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addPotionEffect(PotionEffect effect)
|
||||
{
|
||||
_potionEffects.add(effect);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import nautilus.game.arcade.game.games.moba.boss.BossManager;
|
||||
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
|
||||
import nautilus.game.arcade.game.games.moba.fountain.MobaFountain;
|
||||
import nautilus.game.arcade.game.games.moba.general.ArrowKBManager;
|
||||
import nautilus.game.arcade.game.games.moba.general.EnderPearlManager;
|
||||
import nautilus.game.arcade.game.games.moba.general.MobaDamageManager;
|
||||
import nautilus.game.arcade.game.games.moba.gold.GoldManager;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
@ -36,6 +37,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaShop;
|
||||
import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager;
|
||||
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
||||
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -134,6 +136,9 @@ public class Moba extends TeamGame
|
||||
// Arrow Knockback
|
||||
_arrowKb = registerManager(new ArrowKBManager(this));
|
||||
|
||||
// Ender Pearls
|
||||
registerManager(new EnderPearlManager());
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
.setGiveCompassToSpecs(true)
|
||||
@ -186,18 +191,18 @@ public class Moba extends TeamGame
|
||||
|
||||
if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam))
|
||||
{
|
||||
suffix = "Unknown";
|
||||
suffix = C.cYellow + " Unknown";
|
||||
}
|
||||
else if (mobaPlayer.getKit() == null)
|
||||
{
|
||||
suffix = "Selecting";
|
||||
suffix = C.cYellow + " Selecting";
|
||||
}
|
||||
else
|
||||
{
|
||||
suffix = mobaPlayer.getKit().GetName();
|
||||
suffix = mobaPlayer.getRole().getChatColor() + " " + mobaPlayer.getKit().GetName();
|
||||
}
|
||||
|
||||
return C.cYellow + " " + suffix + C.Reset;
|
||||
return suffix + C.Reset;
|
||||
})
|
||||
.setUnderNameObjective(C.cRed + "❤")
|
||||
.setUnderName((perspective, subject) ->
|
||||
@ -367,7 +372,7 @@ public class Moba extends TeamGame
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
_playerData.add(new MobaPlayer(player));
|
||||
player.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), GetTeam(player).GetName()));
|
||||
MobaUtil.setTeamEntity(player, GetTeam(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,50 +1,24 @@
|
||||
package nautilus.game.arcade.game.games.moba;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
|
||||
public enum MobaRole
|
||||
{
|
||||
|
||||
ASSASSIN("Assassin", new String[]
|
||||
{
|
||||
|
||||
"You are playing",
|
||||
"the " + C.cAqua + "Assassin" + C.cWhite + " role this game",
|
||||
|
||||
}, Color.BLUE, ChatColor.AQUA),
|
||||
HUNTER("Hunter", new String[]
|
||||
{
|
||||
"You are playing",
|
||||
"the " + C.cGreen + "Hunter" + C.cWhite + " role this game",
|
||||
|
||||
}, Color.LIME, ChatColor.GREEN),
|
||||
MAGE("Mage", new String[]
|
||||
{
|
||||
|
||||
"You are playing",
|
||||
"the " + C.cRed + "Mage" + C.cWhite + " role this game",
|
||||
|
||||
}, Color.RED, ChatColor.RED),
|
||||
WARRIOR("Warrior", new String[]
|
||||
{
|
||||
|
||||
"You are playing",
|
||||
"the " + C.cGold + "Warrior" + C.cWhite + " role this game",
|
||||
|
||||
}, Color.YELLOW, ChatColor.GOLD),
|
||||
ASSASSIN("Assassin", Color.GRAY, ChatColor.DARK_GRAY),
|
||||
HUNTER("Hunter", Color.LIME, ChatColor.GREEN),
|
||||
MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE),
|
||||
WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD),
|
||||
;
|
||||
|
||||
private final String _name;
|
||||
private final String[] _description;
|
||||
private final Color _color;
|
||||
private final ChatColor _chatColor;
|
||||
|
||||
MobaRole(String name, String[] description, Color color, ChatColor chatColor)
|
||||
MobaRole(String name, Color color, ChatColor chatColor)
|
||||
{
|
||||
_name = name;
|
||||
_description = description;
|
||||
_color = color;
|
||||
_chatColor = chatColor;
|
||||
}
|
||||
@ -54,11 +28,6 @@ public enum MobaRole
|
||||
return _name;
|
||||
}
|
||||
|
||||
public String[] getDescription()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return _color;
|
||||
|
@ -0,0 +1,20 @@
|
||||
package nautilus.game.arcade.game.games.moba.buff;
|
||||
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class Buff
|
||||
{
|
||||
|
||||
private final LivingEntity _entity;
|
||||
|
||||
public Buff(LivingEntity entity)
|
||||
{
|
||||
_entity = entity;
|
||||
}
|
||||
|
||||
public abstract void onApply(Player player);
|
||||
|
||||
public abstract void onUpdate(UpdateEvent event);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package nautilus.game.arcade.game.games.moba.buff;
|
||||
|
||||
import mineplex.minecraft.game.core.condition.Condition;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class BuffManager implements Listener
|
||||
{
|
||||
|
||||
private final Moba _host;
|
||||
|
||||
public BuffManager(Moba host)
|
||||
{
|
||||
_host = host;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package nautilus.game.arcade.game.games.moba.buff.buffs;
|
||||
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.buff.Buff;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class BuffPumpkinKing extends Buff
|
||||
{
|
||||
|
||||
public BuffPumpkinKing(LivingEntity entity)
|
||||
{
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package nautilus.game.arcade.game.games.moba.general;
|
||||
|
||||
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.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class EnderPearlManager implements Listener
|
||||
{
|
||||
|
||||
private static final int MAX_TICKS = 2 * 20;
|
||||
private final Map<Player, Projectile> _pearls;
|
||||
|
||||
public EnderPearlManager()
|
||||
{
|
||||
_pearls = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void projectileLaunch(ProjectileLaunchEvent event)
|
||||
{
|
||||
Projectile entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof EnderPearl) || !(entity.getShooter() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player shooter = (Player) event.getEntity().getShooter();
|
||||
|
||||
_pearls.put(shooter, event.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<Player> iterator = _pearls.keySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Player shooter = iterator.next();
|
||||
Projectile entity = _pearls.get(shooter);
|
||||
|
||||
if (UtilPlayer.isSpectator(shooter))
|
||||
{
|
||||
iterator.remove();
|
||||
entity.remove();
|
||||
}
|
||||
else if (entity.getTicksLived() > MAX_TICKS)
|
||||
{
|
||||
teleport(shooter, entity);
|
||||
entity.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, entity.getLocation(), 0, 0, 0, 0.1F, 3, ViewDist.LONG);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void projectileHit(ProjectileHitEvent event)
|
||||
{
|
||||
ProjectileSource source = event.getEntity().getShooter();
|
||||
|
||||
if (_pearls.remove(source) != null)
|
||||
{
|
||||
teleport((Player) source, event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
private void teleport(Player shooter, Projectile entity)
|
||||
{
|
||||
Location toTeleport = entity.getLocation();
|
||||
Location playerLocation = shooter.getLocation();
|
||||
toTeleport.setYaw(playerLocation.getYaw());
|
||||
toTeleport.setPitch(playerLocation.getPitch());
|
||||
|
||||
shooter.teleport(toTeleport);
|
||||
}
|
||||
}
|
@ -1,6 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.moba.kit;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -160,28 +165,43 @@ public class HeroKit extends Kit
|
||||
inventory.setItem(AMMO_SLOT, _ammo);
|
||||
inventory.setItem(RECALL_SLOT, RECALL_ITEM);
|
||||
|
||||
// Give armour
|
||||
List<MobaItem> items = ((Moba) Manager.GetGame()).getShop().getOwnedItems(player);
|
||||
Moba game = (Moba) Manager.GetGame();
|
||||
List<MobaItem> items = game.getShop().getOwnedItems(player);
|
||||
|
||||
for (MobaItem item : items)
|
||||
{
|
||||
ItemStack armour = item.getItem();
|
||||
ItemStack itemstack = item.getItem();
|
||||
|
||||
if (UtilItem.isHelmet(armour))
|
||||
// Give armour
|
||||
if (UtilItem.isHelmet(itemstack))
|
||||
{
|
||||
inventory.setHelmet(armour);
|
||||
inventory.setHelmet(itemstack);
|
||||
}
|
||||
else if (UtilItem.isChestplate(armour))
|
||||
else if (UtilItem.isChestplate(itemstack))
|
||||
{
|
||||
inventory.setChestplate(armour);
|
||||
inventory.setChestplate(itemstack);
|
||||
}
|
||||
else if (UtilItem.isLeggings(armour))
|
||||
else if (UtilItem.isLeggings(itemstack))
|
||||
{
|
||||
inventory.setLeggings(armour);
|
||||
inventory.setLeggings(itemstack);
|
||||
}
|
||||
else if (UtilItem.isBoots(armour))
|
||||
else if (UtilItem.isBoots(itemstack))
|
||||
{
|
||||
inventory.setBoots(armour);
|
||||
inventory.setBoots(itemstack);
|
||||
}
|
||||
|
||||
// Give consumable items
|
||||
else if (!UtilItem.isSword(itemstack) && !UtilGear.isBow(itemstack))
|
||||
{
|
||||
// Keep moving left from the ammo slot until a free slot is available
|
||||
for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--)
|
||||
{
|
||||
if (inventory.getItem(i) == null)
|
||||
{
|
||||
inventory.setItem(i, itemstack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,12 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -248,7 +250,7 @@ public class HeroSkill extends Perk
|
||||
}
|
||||
|
||||
|
||||
public void useSkill(Player player)
|
||||
public void useSkill(Player player)
|
||||
{
|
||||
_lastSkill.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
if (_cooldown > 0 && !UtilPlayer.isSpectator(player))
|
||||
@ -257,6 +259,21 @@ public class HeroSkill extends Perk
|
||||
}
|
||||
}
|
||||
|
||||
protected void broadcast(Player player)
|
||||
{
|
||||
Moba game = (Moba) Manager.GetGame();
|
||||
GameTeam team = game.GetTeam(player);
|
||||
HeroKit kit = game.getMobaData(player).getKit();
|
||||
|
||||
if (team == null || kit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
game.Announce(team.GetColor() + C.Bold + player.getName() + " " + kit.getRole().getChatColor() + kit.GetName() + C.cWhiteB + " activated their " + team.GetColor() + C.Bold + GetName() + C.cWhiteB + ".", false);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0.5F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCooldowns(UpdateEvent event)
|
||||
{
|
||||
@ -269,7 +286,7 @@ public class HeroSkill extends Perk
|
||||
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId()))
|
||||
if (!hasPerk(player) || !_lastSkill.containsKey(player.getUniqueId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
|
||||
@ -15,7 +14,11 @@ import nautilus.game.arcade.kit.perks.data.MeteorShowerData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LargeFireball;
|
||||
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.EntityChangeBlockEvent;
|
||||
@ -56,9 +59,12 @@ public class SkillMeteor extends HeroSkill implements IThrown
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!Recharge.Instance.use(player, GetName() + " Trigger", 10000, false, false))
|
||||
for (MeteorShowerData data : _data)
|
||||
{
|
||||
return;
|
||||
if (data.Shooter.equals(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0);
|
||||
@ -66,6 +72,7 @@ public class SkillMeteor extends HeroSkill implements IThrown
|
||||
|
||||
Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F);
|
||||
|
||||
broadcast(player);
|
||||
useActiveSkill(player, 7000);
|
||||
}
|
||||
|
||||
|
@ -126,12 +126,7 @@ public class SkillBiffDash extends HeroSkill
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Location location = UtilAlg.getRandomLocation(entity.getEyeLocation(), 3);
|
||||
entity.getWorld().playEffect(location, Effect.STEP_SOUND, Material.GRASS, 0);
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG);
|
||||
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName());
|
||||
UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0));
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
|
||||
import nautilus.game.arcade.game.games.moba.kit.common.LeashedEntity;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -14,6 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -30,7 +32,7 @@ public class SkillLeash extends HeroSkill
|
||||
|
||||
private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH);
|
||||
|
||||
private final Map<Player, List<Player>> _leashed = new HashMap<>();
|
||||
private final Map<Player, List<LeashedEntity>> _leashed = new HashMap<>();
|
||||
|
||||
public SkillLeash(int slot)
|
||||
{
|
||||
@ -56,7 +58,7 @@ public class SkillLeash extends HeroSkill
|
||||
return;
|
||||
}
|
||||
|
||||
_leashed.put(player, nearbyPlayers);
|
||||
List<LeashedEntity> leashedEntities = new ArrayList<>(nearbyPlayers.size());
|
||||
|
||||
StringBuilder builder = new StringBuilder(F.main("Game", "You leashed "));
|
||||
|
||||
@ -68,13 +70,16 @@ public class SkillLeash extends HeroSkill
|
||||
nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you."));
|
||||
builder.append(F.name(player.getName())).append(", ");
|
||||
Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false);
|
||||
leashedEntities.add(new LeashedEntity(Manager, nearby, player));
|
||||
}
|
||||
|
||||
_leashed.put(player, leashedEntities);
|
||||
|
||||
player.sendMessage(builder.toString());
|
||||
|
||||
useActiveSkill(() ->
|
||||
{
|
||||
for (Player leashed : _leashed.remove(player))
|
||||
for (LeashedEntity leashed : _leashed.remove(player))
|
||||
{
|
||||
removeEffect(leashed);
|
||||
}
|
||||
@ -90,15 +95,15 @@ public class SkillLeash extends HeroSkill
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entry<Player, List<Player>> entry : _leashed.entrySet())
|
||||
for (Entry<Player, List<LeashedEntity>> entry : _leashed.entrySet())
|
||||
{
|
||||
Iterator<Player> iterator = entry.getValue().iterator();
|
||||
Iterator<LeashedEntity> iterator = entry.getValue().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Player leashed = iterator.next();
|
||||
LeashedEntity leashed = iterator.next();
|
||||
|
||||
if (UtilMath.offsetSquared(entry.getKey(), leashed) < 25)
|
||||
if (UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 25)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -109,9 +114,9 @@ public class SkillLeash extends HeroSkill
|
||||
}
|
||||
}
|
||||
|
||||
private void removeEffect(Player player)
|
||||
private void removeEffect(LeashedEntity entity)
|
||||
{
|
||||
player.setLeashHolder(null);
|
||||
player.removePotionEffect(PotionEffectType.SLOW);
|
||||
entity.getHost().removePotionEffect(PotionEffectType.SLOW);
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.moba.kit.biff;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -7,6 +8,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -63,18 +65,19 @@ public class SkillWarHorse extends HeroSkill
|
||||
|
||||
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
|
||||
|
||||
UtilEnt.vegetate(horse);
|
||||
horse.setJumpStrength(0);
|
||||
horse.setMaxDomestication(1);
|
||||
horse.setDomestication(horse.getMaxDomestication());
|
||||
horse.getInventory().setArmor(HORSE_ARMOUR);
|
||||
horse.setOwner(player);
|
||||
horse.setPassenger(player);
|
||||
horse.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetName()));
|
||||
MobaUtil.setTeamEntity(horse, Manager.GetGame().GetTeam(player));
|
||||
|
||||
Manager.GetGame().CreatureAllowOverride = false;
|
||||
|
||||
_data.add(new WarHorseData(player, horse));
|
||||
|
||||
broadcast(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -91,6 +91,7 @@ public class SkillBuildPainting extends HeroSkill implements IThrown
|
||||
}
|
||||
|
||||
useActiveSkill(player, 4000);
|
||||
broadcast(player);
|
||||
|
||||
Set<Block> blocks = new HashSet<>();
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
package nautilus.game.arcade.game.games.moba.kit.common;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class LeashedEntity implements Listener
|
||||
{
|
||||
|
||||
private final LivingEntity _host;
|
||||
private final Zombie _fakeLeash;
|
||||
|
||||
public LeashedEntity(ArcadeManager manager, LivingEntity host, LivingEntity leasher)
|
||||
{
|
||||
manager.GetGame().CreatureAllowOverride = true;
|
||||
|
||||
_host = host;
|
||||
_fakeLeash = host.getWorld().spawn(host.getLocation(), Zombie.class);
|
||||
UtilEnt.vegetate(_fakeLeash);
|
||||
UtilEnt.silence(_fakeLeash, true);
|
||||
_fakeLeash.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false));
|
||||
_fakeLeash.setBaby(true);
|
||||
_fakeLeash.setLeashHolder(leasher);
|
||||
|
||||
manager.GetGame().CreatureAllowOverride = false;
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
_fakeLeash.setLeashHolder(null);
|
||||
_fakeLeash.remove();
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = _host.getLocation();
|
||||
((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY() + 0.8, location.getZ());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void fakeLeashDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageeEntity().equals(_fakeLeash) && event.GetCause() == DamageCause.ENTITY_ATTACK)
|
||||
{
|
||||
event.setDamagee(_host);
|
||||
event.SetIgnoreRate(false);
|
||||
}
|
||||
}
|
||||
|
||||
public LivingEntity getHost()
|
||||
{
|
||||
return _host;
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@ public class SkillRally extends HeroSkill
|
||||
|
||||
UtilAction.velocity(player, vector);
|
||||
_data.add(new RallyData(player));
|
||||
broadcast(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
@ -69,6 +68,7 @@ public class SkillInfinity extends HeroSkill
|
||||
bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
|
||||
_active.add(player);
|
||||
|
||||
broadcast(player);
|
||||
useActiveSkill(() ->
|
||||
{
|
||||
bow.removeEnchantment(Enchantment.ARROW_INFINITE);
|
||||
|
@ -62,7 +62,7 @@ public class SkillTNTArrows extends HeroSkill
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_playerArrows.put(player, 3);
|
||||
player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1);
|
||||
UtilInv.addDullEnchantment(player.getItemInHand());
|
||||
player.getItemInHand().setAmount(3);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
@ -52,7 +53,7 @@ public class SkillNinjaBlade extends HeroSkill
|
||||
@EventHandler
|
||||
public void interact(PlayerInteractEvent event)
|
||||
{
|
||||
if (!isSkillItem(event))
|
||||
if (!isSkillItem(event) || _active.containsKey(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -93,9 +94,20 @@ public class SkillNinjaBlade extends HeroSkill
|
||||
|
||||
_active.put(player.getUniqueId(), damage);
|
||||
|
||||
int i = 0;
|
||||
for (ItemStack itemStack : inventory.getContents())
|
||||
{
|
||||
if (!itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack))
|
||||
{
|
||||
inventory.setItem(i, null);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
broadcast(player);
|
||||
useActiveSkill(() ->
|
||||
{
|
||||
|
||||
_active.remove(player.getUniqueId());
|
||||
|
||||
for (Perk perk : Kit.GetPerks())
|
||||
|
@ -15,6 +15,7 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss;
|
||||
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
|
||||
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -88,9 +89,7 @@ public class MinionWave implements Listener
|
||||
_host.CreatureAllowOverride = true;
|
||||
|
||||
Minion minion = new Minion(_path.get(0), _clazz, _superMinions);
|
||||
|
||||
minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName()));
|
||||
|
||||
MobaUtil.setTeamEntity(minion.getEntity(), _owner);
|
||||
_minions.add(minion);
|
||||
|
||||
_host.CreatureAllowOverride = false;
|
||||
|
@ -1,109 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.moba.prepare;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.MobaPlayer;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PrepareInformation implements Listener
|
||||
{
|
||||
|
||||
private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(3);
|
||||
private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5);
|
||||
|
||||
private final Moba _host;
|
||||
|
||||
private long _lastMessage;
|
||||
private int _messageIndex;
|
||||
|
||||
public PrepareInformation(Moba host)
|
||||
{
|
||||
_host = host;
|
||||
|
||||
// How long should the prepare time be.
|
||||
int longestDescription = 0;
|
||||
for (MobaRole role : MobaRole.values())
|
||||
{
|
||||
int length = role.getDescription().length;
|
||||
|
||||
if (length > longestDescription)
|
||||
{
|
||||
longestDescription = length;
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the prepare time
|
||||
_host.PrepareTime = longestDescription * MESSAGE_TIME + 1000;
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateMessages(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST || !UtilTime.elapsed(_lastMessage, MESSAGE_TIME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (MobaPlayer mobaPlayer : _host.getMobaData())
|
||||
{
|
||||
String[] description = mobaPlayer.getRole().getDescription();
|
||||
|
||||
// Description is too short
|
||||
if (description.length <= _messageIndex + 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
UtilTextMiddle.display(description[_messageIndex], description[_messageIndex + 1], 0, MESSAGE_TIME_TICKS, 0, mobaPlayer.getPlayer());
|
||||
}
|
||||
|
||||
_messageIndex++;
|
||||
_lastMessage = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
|
||||
// Player hasn't moved along the X or Z axis
|
||||
if (to.getX() == from.getX() && to.getZ() == from.getZ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setTo(from);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void live(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
}
|
@ -14,15 +14,12 @@ import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
|
||||
import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent;
|
||||
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -30,10 +27,12 @@ public class PrepareManager implements Listener
|
||||
{
|
||||
|
||||
private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1);
|
||||
private static final long POST_SELECTION_PREPARE_TIME = TimeUnit.SECONDS.toMillis(5);
|
||||
private static final int MAX_DISTANCE_WITHOUT_SELECTION_SQUARED = 400;
|
||||
|
||||
private final Moba _host;
|
||||
|
||||
private boolean _informationStage;
|
||||
private boolean _postPrepareStage;
|
||||
|
||||
public PrepareManager(Moba host)
|
||||
{
|
||||
@ -43,7 +42,7 @@ public class PrepareManager implements Listener
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void updatePrepare(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _informationStage)
|
||||
if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _postPrepareStage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -61,7 +60,7 @@ public class PrepareManager implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
_informationStage = true;
|
||||
_postPrepareStage = true;
|
||||
|
||||
_host.AnnounceGame();
|
||||
_host.StartPrepareCountdown();
|
||||
@ -95,9 +94,29 @@ public class PrepareManager implements Listener
|
||||
|
||||
_host.SetStateTime(System.currentTimeMillis());
|
||||
_host.getArcadeManager().GetChat().Silence(-1, false);
|
||||
_host.PrepareTime = POST_SELECTION_PREPARE_TIME;
|
||||
_host.PrepareFreeze = true;
|
||||
}
|
||||
|
||||
// Start the pregame role information
|
||||
new PrepareInformation(_host);
|
||||
@EventHandler
|
||||
public void updateNearSpawn(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW || _host.GetState() != GameState.Prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (MobaPlayer mobaPlayer : _host.getMobaData())
|
||||
{
|
||||
Player player = mobaPlayer.getPlayer();
|
||||
GameTeam team = _host.GetTeam(player);
|
||||
|
||||
if (UtilMath.offsetSquared(player.getLocation(), team.GetSpawns().get(0)) > MAX_DISTANCE_WITHOUT_SELECTION_SQUARED && (mobaPlayer.getRole() == null || mobaPlayer.getKit() == null))
|
||||
{
|
||||
player.sendMessage(F.main("Game", "You haven't finished selecting your hero."));
|
||||
team.SpawnTeleport(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -73,7 +73,7 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
|
||||
UtilServer.runSyncLater(() ->
|
||||
{
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
displayRoleInformation(player);
|
||||
}
|
||||
@ -235,12 +235,18 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
|
||||
private void displayRoleInformation(Player player)
|
||||
{
|
||||
UtilTextMiddle.display(C.cYellowB + "Role", "Select the role you would like to play", 10, 40, 10, player);
|
||||
String base = "Select the role you would like to play!";
|
||||
|
||||
UtilTextMiddle.display(C.cYellowB + "Role", base, 10, 40, 10, player);
|
||||
player.sendMessage(F.main("Game", base));
|
||||
}
|
||||
|
||||
private void displayKitInformation(Player player, MobaRole role)
|
||||
{
|
||||
String base = "Select your " + role.getChatColor() + "Hero";
|
||||
|
||||
UtilTextMiddle.display(role.getChatColor() + role.getName(), "Select your " + role.getChatColor() + "Hero", 10, 40, 10, player);
|
||||
player.sendMessage(F.main("Game", base + C.mBody + "!"));
|
||||
}
|
||||
|
||||
// Unregister
|
||||
|
@ -2,7 +2,9 @@ package nautilus.game.arcade.game.games.moba.shop;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.leaderboard.Leaderboard;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -1,6 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.moba.shop;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||
@ -21,7 +26,9 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop;
|
||||
import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop;
|
||||
import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -29,9 +36,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -42,6 +54,11 @@ import java.util.Map.Entry;
|
||||
public class MobaShop implements Listener
|
||||
{
|
||||
|
||||
private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT)
|
||||
.setTitle(C.cGold + "Open Gold Upgrades")
|
||||
.addLore("Click to open the Gold Upgrades", "shop while you are respawning.")
|
||||
.build();
|
||||
|
||||
private final Moba _host;
|
||||
private final Map<LivingEntity, Location> _entities;
|
||||
private final Map<MobaRole, MobaShopMenu> _roleMenus;
|
||||
@ -84,6 +101,7 @@ public class MobaShop implements Listener
|
||||
UtilEnt.vegetate(villager);
|
||||
UtilEnt.silence(villager, true);
|
||||
UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation())));
|
||||
((CraftLivingEntity) villager).getHandle().k = false;
|
||||
|
||||
_entities.put(villager, location);
|
||||
}
|
||||
@ -92,7 +110,7 @@ public class MobaShop implements Listener
|
||||
|
||||
public void openShop(MobaPlayer player)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(player.getPlayer()) || _host.GetState() != GameState.Live)
|
||||
if (_host.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -153,7 +171,7 @@ public class MobaShop implements Listener
|
||||
|
||||
private void npcInteract(Entity clicked, Entity clicker)
|
||||
{
|
||||
if (!(clicker instanceof Player))
|
||||
if (!(clicker instanceof Player) || UtilPlayer.isSpectator(clicker))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -183,6 +201,11 @@ public class MobaShop implements Listener
|
||||
List<MobaItem> owned = _upgrades.get(player);
|
||||
MobaShopCategory category = getCategory(item);
|
||||
|
||||
if (category == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!category.isAllowingMultiple())
|
||||
{
|
||||
owned.removeIf(previousItem -> getCategory(previousItem) == category);
|
||||
@ -191,6 +214,14 @@ public class MobaShop implements Listener
|
||||
player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + "."));
|
||||
_host.getGoldManager().removeGold(player, item.getCost());
|
||||
owned.add(item);
|
||||
category.purchase(player);
|
||||
|
||||
// This would happen when the player is respawning and is purchasing upgrades
|
||||
// In this case giving them the item is not needed
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn,
|
||||
// Prevents infinite speed
|
||||
@ -236,6 +267,82 @@ public class MobaShop implements Listener
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
Allow players to access the shop while dead.
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
final Player player = event.getEntity();
|
||||
|
||||
_host.getArcadeManager().runSyncLater(() ->
|
||||
{
|
||||
// Certain categories such as consumables drop on death so here we remove them from upgrades
|
||||
List<MobaItem> owned = _upgrades.get(player);
|
||||
|
||||
if (owned != null)
|
||||
{
|
||||
owned.removeIf(item ->
|
||||
{
|
||||
MobaShopCategory category = getCategory(item);
|
||||
return category == null || category.isDroppingOnDeath();
|
||||
});
|
||||
|
||||
// Reset the max amount of purchasable items
|
||||
MobaPlayer mobaPlayer = _host.getMobaData(player);
|
||||
|
||||
if (mobaPlayer == null || mobaPlayer.getRole() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_roleMenus.get(mobaPlayer.getRole()).getCategories().forEach(category -> category.onDeath(player));
|
||||
}
|
||||
|
||||
// Give the player their kit items
|
||||
Kit kit = _host.GetKit(player);
|
||||
|
||||
if (kit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
kit.GiveItems(player);
|
||||
player.getInventory().setItem(8, SHOP_ITEM);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void interactShopItem(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getItem() == null || !event.getItem().isSimilar(SHOP_ITEM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MobaPlayer mobaPlayer = _host.getMobaData(event.getPlayer());
|
||||
|
||||
if (mobaPlayer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
openShop(mobaPlayer);
|
||||
}
|
||||
|
||||
/*
|
||||
Remove empty potions
|
||||
*/
|
||||
@EventHandler
|
||||
public void removeEmptyPotions(PlayerItemConsumeEvent event)
|
||||
{
|
||||
if (event.getItem().getType() == Material.POTION)
|
||||
{
|
||||
_host.getArcadeManager().runSyncLater(() -> event.getPlayer().setItemInHand(null), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Handle MobaItem events
|
||||
*/
|
||||
@ -294,9 +401,14 @@ public class MobaShop implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void damage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
|
||||
@ -396,9 +508,14 @@ public class MobaShop implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void conditionApply(ConditionApplyEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity entity = event.GetCondition().GetEnt();
|
||||
|
||||
if (!(entity instanceof Player))
|
||||
@ -409,11 +526,6 @@ public class MobaShop implements Listener
|
||||
Player player = (Player) entity;
|
||||
List<MobaItem> items = _upgrades.get(player);
|
||||
|
||||
if (_upgrades == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (MobaItem item : items)
|
||||
{
|
||||
if (item.getEffects() == null)
|
||||
|
@ -1,8 +1,12 @@
|
||||
package nautilus.game.arcade.game.games.moba.shop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MobaShopCategory
|
||||
{
|
||||
@ -10,13 +14,17 @@ public class MobaShopCategory
|
||||
private final String _name;
|
||||
private final List<MobaItem> _items;
|
||||
private final ItemStack _menuItem;
|
||||
private boolean _allowMultiple;
|
||||
private final Map<UUID, Integer> _purchased;
|
||||
private int _max;
|
||||
private boolean _dropOnDeath;
|
||||
|
||||
public MobaShopCategory(String name, List<MobaItem> items, ItemStack menuItem)
|
||||
{
|
||||
_name = name;
|
||||
_items = items;
|
||||
_menuItem = menuItem;
|
||||
_max = Integer.MAX_VALUE;
|
||||
_purchased = new HashMap<>();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@ -34,14 +42,57 @@ public class MobaShopCategory
|
||||
return _menuItem;
|
||||
}
|
||||
|
||||
public MobaShopCategory allowMultiple(boolean allow)
|
||||
public void purchase(Player player)
|
||||
{
|
||||
_allowMultiple = allow;
|
||||
UUID key = player.getUniqueId();
|
||||
|
||||
if (!_purchased.containsKey(key))
|
||||
{
|
||||
_purchased.put(key, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_purchased.put(key, _purchased.get(key) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDeath(Player player)
|
||||
{
|
||||
if (isDroppingOnDeath())
|
||||
{
|
||||
_purchased.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public int getPurchased(Player player)
|
||||
{
|
||||
return _purchased.getOrDefault(player.getUniqueId(), 0);
|
||||
}
|
||||
|
||||
public MobaShopCategory setMax(int max)
|
||||
{
|
||||
_max = max;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMax()
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
|
||||
public MobaShopCategory dropOnDeath()
|
||||
{
|
||||
_dropOnDeath = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDroppingOnDeath()
|
||||
{
|
||||
return _dropOnDeath;
|
||||
}
|
||||
|
||||
public boolean isAllowingMultiple()
|
||||
{
|
||||
return _allowMultiple;
|
||||
return _max < Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
|
||||
ItemBuilder builder = new ItemBuilder(item.getItem());
|
||||
boolean owns = _shop.ownsItem(player, item);
|
||||
boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost());
|
||||
boolean maxed = _category.getPurchased(player) == _category.getMax();
|
||||
int gold = _host.getGoldManager().getGold(player);
|
||||
|
||||
builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName());
|
||||
@ -61,7 +62,11 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
|
||||
{
|
||||
builder.addLore(C.cWhite + "Cost: " + C.cGold + item.getCost(), C.cWhite + "Your Gold: " + C.cGold + gold, "");
|
||||
|
||||
if (canPurchase)
|
||||
if (maxed)
|
||||
{
|
||||
builder.addLore(C.cRed + "You have already purchased the maximum amount", C.cRed + "of upgrades from this category.");
|
||||
}
|
||||
else if (canPurchase)
|
||||
{
|
||||
builder.addLore(C.cGreen + "Click to purchase.");
|
||||
}
|
||||
@ -100,8 +105,9 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
|
||||
{
|
||||
boolean owns = _shop.ownsItem(player, _item);
|
||||
boolean canPurchase = _host.getGoldManager().hasGold(player, _item.getCost());
|
||||
boolean maxed = _category.getPurchased(player) == _category.getMax();
|
||||
|
||||
if (!owns && canPurchase)
|
||||
if (!owns && canPurchase && !maxed)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.6F);
|
||||
_shop.purchaseItem(player, _item);
|
||||
|
@ -8,16 +8,41 @@ import mineplex.core.menu.Menu;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MobaShopMenu extends Menu<ArcadeManager>
|
||||
{
|
||||
|
||||
private static final MobaShopCategory CONSUMABLES = new MobaShopCategory("Consumables", Arrays.asList(
|
||||
new MobaItem(new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cGreenB + "Small Health Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0))
|
||||
.build(), 100),
|
||||
new MobaItem(new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cYellowB + "Large Health Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1))
|
||||
.build(), 200),
|
||||
new MobaItem(new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cYellowB + "Power Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 90 * 20, 0))
|
||||
.build(), 1000),
|
||||
new MobaItem(new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cYellowB + "Speed Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 180 * 20, 0))
|
||||
.build(), 500),
|
||||
new MobaItem(new ItemBuilder(Material.ENDER_PEARL)
|
||||
.setTitle(C.cYellowB + "Ender Pearl")
|
||||
.build(), 750)
|
||||
), new ItemStack(Material.POTION)).dropOnDeath().setMax(3);
|
||||
private static final int SLOTS = 27;
|
||||
|
||||
private final Moba _host;
|
||||
@ -38,6 +63,11 @@ public class MobaShopMenu extends Menu<ArcadeManager>
|
||||
_categories.add(category);
|
||||
}
|
||||
|
||||
protected void addConsumables()
|
||||
{
|
||||
_categories.add(CONSUMABLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Button[] setUp(Player player)
|
||||
{
|
||||
|
@ -124,5 +124,6 @@ public class MobaAssassinShop extends MobaShopMenu
|
||||
addCategory(CHESTPLATE);
|
||||
addCategory(LEGGINGS);
|
||||
addCategory(BOOTS);
|
||||
addConsumables();
|
||||
}
|
||||
}
|
||||
|
@ -203,5 +203,6 @@ public class MobaHunterShop extends MobaShopMenu
|
||||
addCategory(CHESTPLATE);
|
||||
addCategory(LEGGINGS);
|
||||
addCategory(BOOTS);
|
||||
addConsumables();
|
||||
}
|
||||
}
|
||||
|
@ -20,34 +20,41 @@ import java.util.Arrays;
|
||||
public class MobaMageShop extends MobaShopMenu
|
||||
{
|
||||
|
||||
// Dark Purple
|
||||
private static final Color ABILITY_DAMAGE_COLOUR = Color.fromBGR(181, 7, 123);
|
||||
// Purple
|
||||
private static final Color COOLDOWN_COLOUR = Color.PURPLE;
|
||||
// Light Purple
|
||||
private static final Color BASIC_DAMAGE_COLOUR = Color.fromBGR(254, 89, 200);
|
||||
|
||||
private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList(
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
|
||||
.setTitle(C.cGreen + "Leather Cap")
|
||||
.build(), 200),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
|
||||
.setTitle(C.cGreen + "Adept's Cap")
|
||||
.setColor(Color.BLACK)
|
||||
.build(), 500)
|
||||
.setColor(ABILITY_DAMAGE_COLOUR)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaAbilityDamageEffect("Adept's Cap", 0.05)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
|
||||
.setTitle(C.cGreen + "Helm of Focus")
|
||||
.setColor(Color.PURPLE)
|
||||
.build(), 500)
|
||||
.setColor(COOLDOWN_COLOUR)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.03)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
|
||||
.setTitle(C.cGreen + "Battle Mage Cap")
|
||||
.setColor(Color.YELLOW)
|
||||
.build(), 500)
|
||||
.setColor(BASIC_DAMAGE_COLOUR)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaBasicAttackDamageEffect("Battle Mage Cap", 0.03)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.GOLD_HELMET)
|
||||
.setTitle(C.cYellow + "Golden Helmet")
|
||||
.build(), 750)
|
||||
.build(), 1000)
|
||||
), new ItemStack(Material.LEATHER_HELMET));
|
||||
|
||||
private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList(
|
||||
@ -56,28 +63,28 @@ public class MobaMageShop extends MobaShopMenu
|
||||
.build(), 400),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
|
||||
.setTitle(C.cGreen + "Adept's Chestplate")
|
||||
.setColor(Color.BLACK)
|
||||
.build(), 1250)
|
||||
.setColor(ABILITY_DAMAGE_COLOUR)
|
||||
.build(), 1500)
|
||||
.addEffects(
|
||||
new MobaAbilityDamageEffect("Adept's Chestplate", 0.15)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
|
||||
.setTitle(C.cGreen + "Chestplate of Focus")
|
||||
.setColor(Color.PURPLE)
|
||||
.build(), 1000)
|
||||
.setColor(COOLDOWN_COLOUR)
|
||||
.build(), 1250)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.1)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
|
||||
.setTitle(C.cGreen + "Battle Mage Chestplate")
|
||||
.setColor(Color.YELLOW)
|
||||
.build(), 1000)
|
||||
.setColor(BASIC_DAMAGE_COLOUR)
|
||||
.build(), 1250)
|
||||
.addEffects(
|
||||
new MobaBasicAttackDamageEffect("Battle Mage Chestplate", 0.1)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.GOLD_CHESTPLATE)
|
||||
.setTitle(C.cYellow + "Golden Chestplate")
|
||||
.build(), 1000)
|
||||
.build(), 1250)
|
||||
), new ItemStack(Material.LEATHER_CHESTPLATE));
|
||||
|
||||
private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList(
|
||||
@ -86,22 +93,22 @@ public class MobaMageShop extends MobaShopMenu
|
||||
.build(), 400),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
|
||||
.setTitle(C.cGreen + "Adept's Leggings")
|
||||
.setColor(Color.BLACK)
|
||||
.build(), 750)
|
||||
.setColor(ABILITY_DAMAGE_COLOUR)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaAbilityDamageEffect("Adept's Leggings", 0.1)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
|
||||
.setTitle(C.cGreen + "Leggings of Focus")
|
||||
.setColor(Color.PURPLE)
|
||||
.build(), 750)
|
||||
.setColor(COOLDOWN_COLOUR)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.05)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
|
||||
.setTitle(C.cGreen + "Battle Mage Leggings")
|
||||
.setColor(Color.YELLOW)
|
||||
.build(), 750)
|
||||
.setColor(BASIC_DAMAGE_COLOUR)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaBasicAttackDamageEffect("Battle Mage Leggings", 0.05)
|
||||
),
|
||||
@ -116,28 +123,28 @@ public class MobaMageShop extends MobaShopMenu
|
||||
.build(), 200),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
|
||||
.setTitle(C.cGreen + "Adept's Boots")
|
||||
.setColor(Color.BLACK)
|
||||
.build(), 500)
|
||||
.setColor(ABILITY_DAMAGE_COLOUR)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaAbilityDamageEffect("Adept's Boots", 0.05)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
|
||||
.setTitle(C.cGreen + "Boots of Focus")
|
||||
.setColor(Color.PURPLE)
|
||||
.build(), 500)
|
||||
.setColor(COOLDOWN_COLOUR)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.03)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
|
||||
.setTitle(C.cGreen + "Battle Mage Boots")
|
||||
.setColor(Color.YELLOW)
|
||||
.build(), 500)
|
||||
.setColor(BASIC_DAMAGE_COLOUR)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaBasicAttackDamageEffect("Battle Mage Boots", 0.03)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.GOLD_BOOTS)
|
||||
.setTitle(C.cYellow + "Golden Boots")
|
||||
.build(), 750)
|
||||
.build(), 1000)
|
||||
), new ItemStack(Material.LEATHER_BOOTS));
|
||||
|
||||
public MobaMageShop(Moba host, MobaShop shop)
|
||||
@ -148,5 +155,6 @@ public class MobaMageShop extends MobaShopMenu
|
||||
addCategory(CHESTPLATE);
|
||||
addCategory(LEGGINGS);
|
||||
addCategory(BOOTS);
|
||||
addConsumables();
|
||||
}
|
||||
}
|
||||
|
@ -48,13 +48,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.03)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.05)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 750)
|
||||
// .addEffects(
|
||||
// new MobaHPRegenEffect(0.05)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
@ -62,13 +62,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.03)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
.setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.05)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
// .setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
// .build(), 750)
|
||||
// .addEffects(
|
||||
// new MobaHPRegenEffect(0.05)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2000)
|
||||
@ -85,13 +85,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(2)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(4)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 1000)
|
||||
// .addEffects(
|
||||
// new MobaTotalHealthEffect(4)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
@ -99,13 +99,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(2)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
.setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(4)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
// .setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
// .build(), 1000)
|
||||
// .addEffects(
|
||||
// new MobaTotalHealthEffect(4)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2500)
|
||||
@ -122,13 +122,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.05)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.07)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 1000)
|
||||
// .addEffects(
|
||||
// new MobaCDREffect(0.07)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
@ -136,13 +136,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.05)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
.setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
.build(), 1000)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.07)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
// .setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
// .build(), 1000)
|
||||
// .addEffects(
|
||||
// new MobaCDREffect(0.07)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2500)
|
||||
@ -159,13 +159,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.04)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.06)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 750)
|
||||
// .addEffects(
|
||||
// new MobaSpeedEffect(0.06)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
@ -173,13 +173,13 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.04)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
.setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
.build(), 750)
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.06)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
// .setTitle(C.cYellowB + "Superior Brawler's Plate")
|
||||
// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2)
|
||||
// .build(), 750)
|
||||
// .addEffects(
|
||||
// new MobaSpeedEffect(0.06)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2000)
|
||||
@ -197,5 +197,6 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
addCategory(CHESTPLATE);
|
||||
addCategory(LEGGINGS);
|
||||
addCategory(BOOTS);
|
||||
addConsumables();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.structure.tower;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
@ -147,6 +148,7 @@ public class TowerManager implements Listener
|
||||
{
|
||||
if (tower.getStand().equals(event.GetDamageeEntity()))
|
||||
{
|
||||
tower.getStand().setFireTicks(0);
|
||||
event.SetCancelled("Tower Guardian");
|
||||
}
|
||||
}
|
||||
@ -169,31 +171,36 @@ public class TowerManager implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getDamager();
|
||||
Entity damager = event.getDamager();
|
||||
Player player = null;
|
||||
Tower tower = null;
|
||||
|
||||
if (entity instanceof Player)
|
||||
for (Tower other : _towers)
|
||||
{
|
||||
player = (Player) entity;
|
||||
if (other.getCrystal().equals(event.getEntity()))
|
||||
{
|
||||
tower = other;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (entity instanceof Projectile)
|
||||
|
||||
if (tower == null)
|
||||
{
|
||||
Projectile projectile = (Projectile) entity;
|
||||
return;
|
||||
}
|
||||
|
||||
if (damager instanceof Player)
|
||||
{
|
||||
player = (Player) damager;
|
||||
}
|
||||
else if (damager instanceof Projectile)
|
||||
{
|
||||
Projectile projectile = (Projectile) damager;
|
||||
ProjectileSource source = projectile.getShooter();
|
||||
|
||||
if (source instanceof Player)
|
||||
{
|
||||
player = (Player) source;
|
||||
|
||||
Location entityLocation = event.getEntity().getLocation();
|
||||
Location playerLocation = player.getLocation();
|
||||
playerLocation.setY(entityLocation.getY());
|
||||
|
||||
if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,26 +211,16 @@ public class TowerManager implements Listener
|
||||
|
||||
GameTeam team = _host.GetTeam(player);
|
||||
|
||||
if (UtilPlayer.isSpectator(player) || team == null)
|
||||
if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Tower tower : _towers)
|
||||
tower.damage(event.getDamage());
|
||||
|
||||
if (Recharge.Instance.use(player, "Tower Sound", 500, false, false))
|
||||
{
|
||||
if (!event.getEntity().equals(tower.getCrystal()) || !canDamage(tower, team))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
tower.damage(event.getDamage());
|
||||
|
||||
if (Recharge.Instance.use(player, "Tower Sound", 500, false, false))
|
||||
{
|
||||
playSound(player, tower);
|
||||
}
|
||||
return;
|
||||
playSound(player, tower);
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +243,8 @@ public class TowerManager implements Listener
|
||||
{
|
||||
Entity entity = iterator.next();
|
||||
Pair<Player, Double> pair = _projectilesToCheck.get(entity);
|
||||
GameTeam team = _host.GetTeam(pair.getLeft());
|
||||
Player player = pair.getLeft();
|
||||
GameTeam team = _host.GetTeam(player);
|
||||
|
||||
for (Tower tower : _towers)
|
||||
{
|
||||
@ -255,14 +253,38 @@ public class TowerManager implements Listener
|
||||
continue;
|
||||
}
|
||||
|
||||
playSound(pair.getLeft(), tower);
|
||||
tower.damage(pair.getRight());
|
||||
if (!shouldCancelDamage(tower, player))
|
||||
{
|
||||
playSound(player, tower);
|
||||
tower.damage(pair.getRight());
|
||||
}
|
||||
|
||||
entity.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldCancelDamage(Tower tower, Player shooter)
|
||||
{
|
||||
Location entityLocation = tower.getCrystal().getLocation();
|
||||
Location playerLocation = shooter.getLocation();
|
||||
playerLocation.setY(entityLocation.getY());
|
||||
|
||||
if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED)
|
||||
{
|
||||
shooter.playSound(shooter.getLocation(), Sound.NOTE_PLING, 1, 0.9F);
|
||||
if (Recharge.Instance.use(shooter, "Tower Cancel Inform", 2000, false, false))
|
||||
{
|
||||
shooter.sendMessage(F.main("Game", "You cannot damage the enemy tower while outside of the circle! Step inside the circle to deal damage to it."));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void playSound(Player player, Tower tower)
|
||||
{
|
||||
player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F);
|
||||
|
@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
@ -12,6 +13,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -185,6 +187,11 @@ public class MobaUtil
|
||||
return C.cGreenB;
|
||||
}
|
||||
|
||||
public static void setTeamEntity(LivingEntity entity, GameTeam team)
|
||||
{
|
||||
entity.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(UtilServer.getPlugin(), team.GetName()));
|
||||
}
|
||||
|
||||
public static boolean isTeamEntity(LivingEntity entity, GameTeam team)
|
||||
{
|
||||
return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName());
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user