Second MOBA map
This commit is contained in:
parent
84bf321fe5
commit
789658b2d9
@ -1215,13 +1215,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
// Re-Give Kit
|
||||
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
GetKit(player).ApplyKit(player);
|
||||
}
|
||||
}, 0);
|
||||
Manager.runSyncLater(() -> GetKit(player).ApplyKit(player), 0);
|
||||
}
|
||||
|
||||
public void RespawnPlayerTeleport(Player player)
|
||||
|
@ -199,9 +199,6 @@ public class Moba extends TeamGame
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
// Register all "Managers"
|
||||
_listeners.forEach(UtilServer::RegisterEvents);
|
||||
|
||||
// Make all spawns face the center of the map
|
||||
for (List<Location> locations : WorldData.SpawnLocs.values())
|
||||
{
|
||||
@ -217,6 +214,7 @@ public class Moba extends TeamGame
|
||||
try
|
||||
{
|
||||
mapType = MobaMapType.valueOf(key);
|
||||
break;
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
@ -269,6 +267,9 @@ public class Moba extends TeamGame
|
||||
_selector = new MapBoardSelector(_board);
|
||||
_selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0));
|
||||
}
|
||||
|
||||
// Register all "Managers"
|
||||
_listeners.forEach(UtilServer::RegisterEvents);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -289,10 +290,7 @@ public class Moba extends TeamGame
|
||||
MobaUtil.setTeamEntity(player, GetTeam(player));
|
||||
}
|
||||
|
||||
// Cleanup tutorial boards
|
||||
_mapManager.cleanupBoard(_board);
|
||||
_selector.cleanup();
|
||||
_progression.removeRoleViewers();
|
||||
cleanupLobby();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -315,6 +313,17 @@ public class Moba extends TeamGame
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
private void cleanupLobby()
|
||||
{
|
||||
if (_mapManager != null)
|
||||
{
|
||||
_mapManager.cleanupBoard(_board);
|
||||
_selector.cleanup();
|
||||
}
|
||||
|
||||
_progression.removeRoleViewers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
@ -322,6 +331,8 @@ public class Moba extends TeamGame
|
||||
_listeners.forEach(UtilServer::Unregister);
|
||||
_listeners.clear();
|
||||
|
||||
cleanupLobby();
|
||||
|
||||
Manager.runSyncLater(() ->
|
||||
{
|
||||
PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class);
|
||||
|
@ -83,6 +83,7 @@ public class BossManager implements Listener
|
||||
public void registerBoss(MobaBoss boss)
|
||||
{
|
||||
_bosses.add(boss);
|
||||
boss.setup();
|
||||
}
|
||||
|
||||
public String getWitherDisplayString(GameTeam team)
|
||||
|
@ -231,7 +231,7 @@ public class PumpkinBoss extends MobaBoss
|
||||
BuffManager buffManager = _host.getBuffManager();
|
||||
for (Player teamMember : team.GetPlayers(true))
|
||||
{
|
||||
buffManager.apply(new BuffPumpkinKing(_host, teamMember, true));
|
||||
buffManager.apply(new BuffPumpkinKing(_host, teamMember, HELMET));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,15 +32,14 @@ public class BuffPumpkinKing extends Buff<Player>
|
||||
private static final long DURATION = TimeUnit.MINUTES.toMillis(1);
|
||||
private static final String DAMAGE_REASON = "Boss Buff";
|
||||
private static final double DAMAGE_FACTOR = 1.5;
|
||||
private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN);
|
||||
|
||||
private boolean _giveHelmet;
|
||||
private final ItemStack _helmet;
|
||||
|
||||
public BuffPumpkinKing(Moba host, Player entity, boolean giveHelmet)
|
||||
public BuffPumpkinKing(Moba host, Player entity, ItemStack helmet)
|
||||
{
|
||||
super(host, entity, DURATION);
|
||||
|
||||
_giveHelmet = giveHelmet;
|
||||
_helmet = helmet;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,27 +48,24 @@ public class BuffPumpkinKing extends Buff<Player>
|
||||
_entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1));
|
||||
UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG);
|
||||
_entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F);
|
||||
_entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + "flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!"));
|
||||
_entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + " flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpire()
|
||||
{
|
||||
if (_giveHelmet)
|
||||
{
|
||||
sendFakeHelmet(_entity, _entity.getInventory().getHelmet());
|
||||
}
|
||||
sendFakeHelmet(_entity, _entity.getInventory().getHelmet());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateFakeHelmet(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW || !_giveHelmet)
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sendFakeHelmet(_entity, HELMET);
|
||||
sendFakeHelmet(_entity, _helmet);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.modes;
|
||||
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class MobaHeroesValleyMap extends MobaMap
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package nautilus.game.arcade.game.games.moba.modes;
|
||||
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
@ -34,6 +35,7 @@ public enum MobaMapType
|
||||
}
|
||||
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package nautilus.game.arcade.game.games.moba.modes;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
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.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilVariant;
|
||||
@ -15,10 +18,10 @@ import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
|
||||
import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
@ -27,19 +30,22 @@ import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MobaMonochromeMap extends MobaMap
|
||||
{
|
||||
|
||||
private static final long START_TIME = TimeUnit.MINUTES.toMillis(1);
|
||||
private static final long START_TIME = TimeUnit.MINUTES.toMillis(5);
|
||||
private static final long ACTIVE_TIME = TimeUnit.SECONDS.toMillis(30);
|
||||
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD);
|
||||
private static final ItemStack BUFF_HELMET = new ItemBuilder(Material.SKULL_ITEM, (byte) 1).build();
|
||||
|
||||
private final Set<LivingEntity> _skeletons;
|
||||
private final Map<GameTeam, Integer> _killedSkeletons;
|
||||
@ -85,14 +91,20 @@ public class MobaMonochromeMap extends MobaMap
|
||||
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F);
|
||||
}
|
||||
|
||||
_host.CreatureAllowOverride = true;
|
||||
|
||||
for (Location location : _host.WorldData.GetDataLocs("BLACK"))
|
||||
{
|
||||
Skeleton skeleton = UtilVariant.spawnWitherSkeleton(location);
|
||||
skeleton.getEquipment().setItemInHand(IN_HAND);
|
||||
skeleton.setCustomName(C.Bold + "Wither Skeleton");
|
||||
skeleton.setCustomNameVisible(true);
|
||||
|
||||
_skeletons.add(skeleton);
|
||||
}
|
||||
|
||||
_host.CreatureAllowOverride = false;
|
||||
|
||||
for (GameTeam team : _host.GetTeamList())
|
||||
{
|
||||
_killedSkeletons.put(team, 0);
|
||||
@ -107,45 +119,71 @@ public class MobaMonochromeMap extends MobaMap
|
||||
return;
|
||||
}
|
||||
|
||||
GameTeam mostKillsTeam = null;
|
||||
int mostKills = 0;
|
||||
GameTeam red = _host.GetTeam(ChatColor.RED);
|
||||
int redKills = _killedSkeletons.get(red);
|
||||
GameTeam blue = _host.GetTeam(ChatColor.AQUA);
|
||||
int blueKills = _killedSkeletons.get(blue);
|
||||
List<GameTeam> winners;
|
||||
|
||||
for (Entry<GameTeam, Integer> entry : _killedSkeletons.entrySet())
|
||||
// Draw
|
||||
if (redKills == blueKills)
|
||||
{
|
||||
GameTeam team = entry.getKey();
|
||||
int kills = entry.getValue();
|
||||
|
||||
if (mostKillsTeam == null || kills > mostKills)
|
||||
{
|
||||
mostKillsTeam = team;
|
||||
mostKills = kills;
|
||||
}
|
||||
// Draw
|
||||
else if (kills == mostKills && mostKills != 0)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
winners = Arrays.asList(red, blue);
|
||||
}
|
||||
// Red win
|
||||
else if (redKills > blueKills)
|
||||
{
|
||||
winners = Collections.singletonList(red);
|
||||
}
|
||||
// Blue win
|
||||
else
|
||||
{
|
||||
winners = Collections.singletonList(blue);
|
||||
}
|
||||
|
||||
if (mostKillsTeam == null)
|
||||
if (winners.size() == 1)
|
||||
{
|
||||
GameTeam winner = winners.get(0);
|
||||
|
||||
_host.Announce(F.main("Game", F.name(winner.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons") + ". They have been given the buff!"), false);
|
||||
UtilTextMiddle.display("", winner.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
_host.Announce(F.main("Game", F.elem(C.Bold + "Draw") + "! No one was given the buff!"), false);
|
||||
UtilTextMiddle.display("", C.cYellowB + "Draw" + C.cWhite + "! No one was given the buff!", 10, 40, 10);
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
_host.Announce(F.main("Game", F.name(mostKillsTeam.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons")), false);
|
||||
UtilTextMiddle.display("", mostKillsTeam.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10);
|
||||
|
||||
// Give the team members the buff
|
||||
BuffManager buffManager = _host.getBuffManager();
|
||||
for (Player teamMember : mostKillsTeam.GetPlayers(true))
|
||||
winners.forEach(team ->
|
||||
{
|
||||
buffManager.apply(new BuffPumpkinKing(_host, teamMember, false));
|
||||
}
|
||||
for (Player teamMember : team.GetPlayers(true))
|
||||
{
|
||||
buffManager.apply(new BuffPumpkinKing(_host, teamMember, BUFF_HELMET));
|
||||
}
|
||||
});
|
||||
|
||||
_skeletons.forEach(Entity::remove);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void cleanup()
|
||||
{
|
||||
_skeletons.forEach(entity ->
|
||||
{
|
||||
if (!entity.isDead())
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, entity.getLocation().add(0, 1.5, 0), 0.5F, 1, 0.5F, 0.001F, 15, ViewDist.LONG);
|
||||
}
|
||||
|
||||
entity.remove();
|
||||
});
|
||||
_skeletons.clear();
|
||||
_killedSkeletons.clear();
|
||||
|
||||
_active = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -169,8 +207,10 @@ public class MobaMonochromeMap extends MobaMap
|
||||
return;
|
||||
}
|
||||
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
_killedSkeletons.put(team, _killedSkeletons.get(team) + 1);
|
||||
player.sendMessage(F.main("Game", "+1"));
|
||||
player.sendMessage(F.main("Game", "You killed a " + F.name("Wither Skeleton") + "!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user