Merge branch 'update/moba-2' into develop

This commit is contained in:
cnr 2017-07-26 21:48:15 -04:00
commit 3fbad35a30
6 changed files with 97 additions and 52 deletions

View File

@ -282,15 +282,18 @@ public class Moba extends TeamGame
setKits(_kits);
// Store player data
for (Player player : GetPlayers(true))
{
_playerData.add(new MobaPlayer(player));
MobaUtil.setTeamEntity(player, GetTeam(player));
}
GetPlayers(true).forEach(this::setupPlayerData);
// Make sure to cleanup
cleanupLobby();
}
public void setupPlayerData(Player player)
{
_playerData.add(new MobaPlayer(player));
MobaUtil.setTeamEntity(player, GetTeam(player));
}
@EventHandler
public void preventOverfill(PlayerPrepareTeleportEvent event)
{

View File

@ -10,7 +10,6 @@ import nautilus.game.arcade.game.games.moba.general.HotJoiningManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.GameStatisticsModule;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity;
@ -98,7 +97,7 @@ public class MobaClassic extends Moba
{
suffix = C.cYellow + " Unknown";
}
else if (mobaPlayer.getKit() == null)
else if (mobaPlayer == null || mobaPlayer.getKit() == null)
{
suffix = C.cYellow + " Selecting";
}

View File

@ -4,6 +4,8 @@ import mineplex.core.common.util.UtilPlayer;
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 org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -36,25 +38,7 @@ public class BuffManager implements Listener
_buffs.get(buff.getEntity()).add(buff);
buff.apply();
}
public boolean hasBuff(LivingEntity entity, Class<? extends Buff<? extends LivingEntity>> clazz)
{
if (!_buffs.containsKey(entity))
{
return false;
}
for (Buff<? extends LivingEntity> buff : _buffs.get(entity))
{
if (buff.getClass().equals(clazz))
{
return true;
}
}
return false;
}
@EventHandler
public void update(UpdateEvent event)
{
@ -91,4 +75,15 @@ public class BuffManager implements Listener
}
}
}
@EventHandler
public void end(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
{
return;
}
_buffs.forEach((livingEntity, buffs) -> buffs.forEach(Buff::expire));
}
}

View File

@ -1,21 +1,26 @@
package nautilus.game.arcade.game.games.moba.general;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent;
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.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class HotJoiningManager implements Listener
{
@ -23,18 +28,22 @@ public class HotJoiningManager implements Listener
private static final int HOT_JOIN_EXP_REWARD = 100;
private final Moba _host;
private final List<Player> _pending;
private final List<Player> _hotJoined;
private final List<UUID> _played;
public HotJoiningManager(Moba host)
{
_host = host;
_pending = new ArrayList<>();
_hotJoined = new ArrayList<>();
_played = new ArrayList<>(8);
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerJoin(PlayerJoinEvent event)
@EventHandler(priority = EventPriority.LOWEST)
public void playerLogin(PlayerLoginEvent event)
{
if (!_host.IsLive())
if (!_host.IsLive() || !_host.getArcadeManager().IsRewardStats())
{
return;
}
@ -42,11 +51,36 @@ public class HotJoiningManager implements Listener
Player player = event.getPlayer();
GameTeam team = _host.ChooseTeam(player);
if (team == null || _host.getArcadeManager().isVanished(player))
if (team == null || team.GetSize() >= 4)
{
return;
}
_pending.add(player);
team.AddPlayer(player, true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (!_pending.remove(player))
{
return;
}
GameTeam team = _host.GetTeam(player);
if (_host.getArcadeManager().isVanished(player))
{
if (team != null)
{
team.RemovePlayer(player);
}
return;
}
for (Tower tower : _host.getTowerManager().getTowers())
{
// If the team's second tower is dead
@ -57,16 +91,34 @@ public class HotJoiningManager implements Listener
}
}
team.AddPlayer(player, true);
boolean played = _played.contains(player.getUniqueId());
team.SpawnTeleport(player);
_hotJoined.add(player);
if (!played)
{
_hotJoined.add(player);
}
_host.setupPlayerData(player);
_host.getArcadeManager().runSyncLater(() ->
{
Kit kit = _host.getFirstKit(player);
player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game you will earn an additional " + HOT_JOIN_EXP_REWARD + " experience points"));
if (!played)
{
player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game you will were an additional " + F.elem(HOT_JOIN_EXP_REWARD) + " " + F.greenElem("Heroes of GWEN Role") + " experience."));
}
_host.SetKit(player, kit, true);
Perk perk = kit.GetPerks()[kit.GetPerks().length - 1];
// Put Ultimates on cooldown
if (perk instanceof HeroSkill)
{
((HeroSkill) perk).useSkill(player);
}
}, 1);
}
@ -74,9 +126,21 @@ public class HotJoiningManager implements Listener
public void playerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
_pending.remove(player);
_hotJoined.remove(player);
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
_host.GetPlayers(true).forEach(player -> _played.add(player.getUniqueId()));
}
@EventHandler
public void expCalculate(MobaExperienceCalculateEvent event)
{

View File

@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (!isSkillItem(event) || _active.contains(event.getPlayer()))
if (!isSkillItem(event))
{
return;
}
@ -66,13 +66,11 @@ public class SkillInfinity extends HeroSkill
// Give 1 arrow just incase the player didn't have one
_kit.giveAmmo(player, 1);
bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
_active.add(player);
broadcast(player);
useActiveSkill(() ->
{
bow.removeEnchantment(Enchantment.ARROW_INFINITE);
_active.remove(player);
}, player, 7000);
}

View File

@ -26,7 +26,6 @@ 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.CraftEntity;
@ -249,6 +248,7 @@ public class MobaShop implements Listener
public List<MobaItem> getOwnedItems(Player player)
{
_upgrades.putIfAbsent(player, new ArrayList<>());
return _upgrades.get(player);
}
@ -329,20 +329,6 @@ public class MobaShop implements Listener
Handle MobaItem events
*/
@EventHandler
public void prepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
for (Player player : _host.GetPlayers(true))
{
_upgrades.put(player, new ArrayList<>());
}
}
@EventHandler
public void ammoGive(AmmoGiveEvent event)
{