Merge branch 'update/moba-2' into develop
This commit is contained in:
commit
5b7f6a94ee
@ -1215,13 +1215,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
// Re-Give Kit
|
// Re-Give Kit
|
||||||
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
Manager.runSyncLater(() -> GetKit(player).ApplyKit(player), 0);
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
GetKit(player).ApplyKit(player);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RespawnPlayerTeleport(Player player)
|
public void RespawnPlayerTeleport(Player player)
|
||||||
|
@ -44,6 +44,7 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager;
|
|||||||
import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa;
|
import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa;
|
||||||
import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena;
|
import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena;
|
||||||
import nautilus.game.arcade.game.games.moba.minion.MinionManager;
|
import nautilus.game.arcade.game.games.moba.minion.MinionManager;
|
||||||
|
import nautilus.game.arcade.game.games.moba.modes.MobaMapType;
|
||||||
import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager;
|
import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager;
|
||||||
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
||||||
import nautilus.game.arcade.game.games.moba.shop.MobaShop;
|
import nautilus.game.arcade.game.games.moba.shop.MobaShop;
|
||||||
@ -195,9 +196,6 @@ public class Moba extends TeamGame
|
|||||||
@Override
|
@Override
|
||||||
public void ParseData()
|
public void ParseData()
|
||||||
{
|
{
|
||||||
// Register all "Managers"
|
|
||||||
_listeners.forEach(UtilServer::RegisterEvents);
|
|
||||||
|
|
||||||
// Make all spawns face the center of the map
|
// Make all spawns face the center of the map
|
||||||
for (List<Location> locations : WorldData.SpawnLocs.values())
|
for (List<Location> locations : WorldData.SpawnLocs.values())
|
||||||
{
|
{
|
||||||
@ -206,49 +204,69 @@ public class Moba extends TeamGame
|
|||||||
|
|
||||||
SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0);
|
SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0);
|
||||||
|
|
||||||
// Leaderboards
|
MobaMapType mapType = null;
|
||||||
if (Manager.IsRewardStats())
|
|
||||||
|
for (String key : WorldData.GetAllCustomLocs().keySet())
|
||||||
{
|
{
|
||||||
if (Manager.GetLobby() instanceof NewGameLobbyManager)
|
try
|
||||||
|
{
|
||||||
|
mapType = MobaMapType.valueOf(key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
Map<String, List<Location>> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs();
|
|
||||||
LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class);
|
|
||||||
Pair<String, String> winPair = Pair.create("Win", "Wins");
|
|
||||||
Pair<String, String> killPair = Pair.create("Kill", "Kills");
|
|
||||||
Pair<String, String> goldPair = Pair.create("Gold", "Gold");
|
|
||||||
|
|
||||||
{
|
|
||||||
Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0);
|
|
||||||
leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0);
|
|
||||||
leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0);
|
|
||||||
leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Location location = lobbyCustomLocs.get("TOP_WINS").get(0);
|
|
||||||
leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Location location = lobbyCustomLocs.get("TOP_KILLS").get(0);
|
|
||||||
leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Location location = lobbyCustomLocs.get("TOP_GOLD").get(0);
|
|
||||||
leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
_progression.spawnRoleViewers(lobbyCustomLocs);
|
|
||||||
|
|
||||||
_board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES);
|
|
||||||
_selector = new MapBoardSelector(_board);
|
|
||||||
_selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mapType == null)
|
||||||
|
{
|
||||||
|
mapType = MobaMapType.HEROES_VALLEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerManager(mapType.createInstance(this));
|
||||||
|
|
||||||
|
if (Manager.IsRewardStats() && Manager.GetLobby() instanceof NewGameLobbyManager)
|
||||||
|
{
|
||||||
|
Map<String, List<Location>> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs();
|
||||||
|
LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class);
|
||||||
|
Pair<String, String> winPair = Pair.create("Win", "Wins");
|
||||||
|
Pair<String, String> killPair = Pair.create("Kill", "Kills");
|
||||||
|
Pair<String, String> goldPair = Pair.create("Gold", "Gold");
|
||||||
|
|
||||||
|
{
|
||||||
|
Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0);
|
||||||
|
leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0);
|
||||||
|
leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0);
|
||||||
|
leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Location location = lobbyCustomLocs.get("TOP_WINS").get(0);
|
||||||
|
leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Location location = lobbyCustomLocs.get("TOP_KILLS").get(0);
|
||||||
|
leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Location location = lobbyCustomLocs.get("TOP_GOLD").get(0);
|
||||||
|
leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
_progression.spawnRoleViewers(lobbyCustomLocs);
|
||||||
|
|
||||||
|
_board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES);
|
||||||
|
_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)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@ -269,10 +287,7 @@ public class Moba extends TeamGame
|
|||||||
MobaUtil.setTeamEntity(player, GetTeam(player));
|
MobaUtil.setTeamEntity(player, GetTeam(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup tutorial boards
|
cleanupLobby();
|
||||||
_mapManager.cleanupBoard(_board);
|
|
||||||
_selector.cleanup();
|
|
||||||
_progression.removeRoleViewers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -295,6 +310,17 @@ public class Moba extends TeamGame
|
|||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cleanupLobby()
|
||||||
|
{
|
||||||
|
if (_mapManager != null && _board != null)
|
||||||
|
{
|
||||||
|
_mapManager.cleanupBoard(_board);
|
||||||
|
_selector.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
_progression.removeRoleViewers();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void disable()
|
||||||
{
|
{
|
||||||
@ -302,6 +328,8 @@ public class Moba extends TeamGame
|
|||||||
_listeners.forEach(UtilServer::Unregister);
|
_listeners.forEach(UtilServer::Unregister);
|
||||||
_listeners.clear();
|
_listeners.clear();
|
||||||
|
|
||||||
|
cleanupLobby();
|
||||||
|
|
||||||
Manager.runSyncLater(() ->
|
Manager.runSyncLater(() ->
|
||||||
{
|
{
|
||||||
PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class);
|
PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class);
|
||||||
|
@ -4,35 +4,36 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
|
|||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import nautilus.game.arcade.game.games.moba.Moba;
|
import nautilus.game.arcade.game.games.moba.Moba;
|
||||||
import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss;
|
|
||||||
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
|
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
|
||||||
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
||||||
import nautilus.game.arcade.world.WorldData;
|
import nautilus.game.arcade.world.WorldData;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class BossManager implements Listener
|
public class BossManager implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Moba _host;
|
private final Moba _host;
|
||||||
|
|
||||||
private Map<GameTeam, WitherBoss> _teamBosses;
|
private final Set<MobaBoss> _bosses;
|
||||||
private PumpkinBoss _pumpkinBoss;
|
private final Map<GameTeam, WitherBoss> _teamBosses;
|
||||||
|
|
||||||
private boolean _dummyBosses;
|
private boolean _dummyBosses;
|
||||||
|
|
||||||
public BossManager(Moba host)
|
public BossManager(Moba host)
|
||||||
{
|
{
|
||||||
_host = host;
|
_host = host;
|
||||||
|
_bosses = new HashSet<>();
|
||||||
_teamBosses = new HashMap<>(2);
|
_teamBosses = new HashMap<>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnBosses()
|
private void spawnTeamWithers()
|
||||||
{
|
{
|
||||||
if (_dummyBosses)
|
if (_dummyBosses)
|
||||||
{
|
{
|
||||||
@ -52,10 +53,6 @@ public class BossManager implements Listener
|
|||||||
_teamBosses.put(team, boss);
|
_teamBosses.put(team, boss);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pumpkin King
|
|
||||||
_pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0));
|
|
||||||
_pumpkinBoss.setup();
|
|
||||||
|
|
||||||
_host.CreatureAllowOverride = false;
|
_host.CreatureAllowOverride = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +64,7 @@ public class BossManager implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnBosses();
|
spawnTeamWithers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -79,17 +76,19 @@ public class BossManager implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
_teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup());
|
_teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup());
|
||||||
|
_bosses.forEach(MobaBoss::cleanup);
|
||||||
|
_bosses.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (_pumpkinBoss != null)
|
public void registerBoss(MobaBoss boss)
|
||||||
{
|
{
|
||||||
_pumpkinBoss.cleanup();
|
_bosses.add(boss);
|
||||||
}
|
boss.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWitherDisplayString(GameTeam team)
|
public String getWitherDisplayString(GameTeam team)
|
||||||
{
|
{
|
||||||
WitherBoss boss = getWitherBoss(team);
|
WitherBoss boss = getWitherBoss(team);
|
||||||
|
|
||||||
return MobaUtil.getColour(boss.getHealthPercentage()) + "♚";
|
return MobaUtil.getColour(boss.getHealthPercentage()) + "♚";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,20 +97,9 @@ public class BossManager implements Listener
|
|||||||
return _teamBosses.get(team);
|
return _teamBosses.get(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MobaBoss> getBosses()
|
public Collection<WitherBoss> getWitherBosses()
|
||||||
{
|
{
|
||||||
List<MobaBoss> bosses = new ArrayList<>();
|
return _teamBosses.values();
|
||||||
|
|
||||||
if (_teamBosses != null)
|
|
||||||
{
|
|
||||||
bosses.addAll(_teamBosses.values());
|
|
||||||
}
|
|
||||||
if (_pumpkinBoss != null)
|
|
||||||
{
|
|
||||||
bosses.add(_pumpkinBoss);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bosses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDummyBosses(boolean dummyBosses)
|
public void setDummyBosses(boolean dummyBosses)
|
||||||
|
@ -113,6 +113,11 @@ public abstract class MobaBoss implements Listener
|
|||||||
getAi().setEntity(_entity);
|
getAi().setEntity(_entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerBoss()
|
||||||
|
{
|
||||||
|
_host.getBossManager().registerBoss(this);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract LivingEntity spawnEntity();
|
public abstract LivingEntity spawnEntity();
|
||||||
|
|
||||||
public abstract MobaAI getAi();
|
public abstract MobaAI getAi();
|
||||||
|
@ -113,7 +113,7 @@ public class PumpkinBoss extends MobaBoss
|
|||||||
getAi().setEntity(skeleton);
|
getAi().setEntity(skeleton);
|
||||||
|
|
||||||
UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10);
|
UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10);
|
||||||
_host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false);
|
_host.Announce(F.main("Game", "The " + F.elem("Pumpkin King") + " has spawned! Killing him will give your team a buff!"), false);
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -125,7 +125,8 @@ public class PumpkinBoss extends MobaBoss
|
|||||||
Block block = entry.getKey();
|
Block block = entry.getKey();
|
||||||
double setChance = entry.getValue();
|
double setChance = entry.getValue();
|
||||||
|
|
||||||
if (!UtilBlock.solid(block)|| block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance)
|
if (!UtilBlock.solid(block) || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() >
|
||||||
|
setChance)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -230,12 +231,7 @@ public class PumpkinBoss extends MobaBoss
|
|||||||
BuffManager buffManager = _host.getBuffManager();
|
BuffManager buffManager = _host.getBuffManager();
|
||||||
for (Player teamMember : team.GetPlayers(true))
|
for (Player teamMember : team.GetPlayers(true))
|
||||||
{
|
{
|
||||||
if (UtilPlayer.isSpectator(teamMember))
|
buffManager.apply(new BuffPumpkinKing(_host, teamMember, HELMET));
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffManager.apply(new BuffPumpkinKing(_host, teamMember));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +279,7 @@ public class PumpkinBoss extends MobaBoss
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_entity.setHealth(Math.min(_entity.getHealth() + HEALTH_OUT_OF_COMBAT, _entity.getMaxHealth()));
|
MobaUtil.heal(_entity, null, HEALTH_OUT_OF_COMBAT);
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import nautilus.game.arcade.game.games.moba.Moba;
|
|||||||
import nautilus.game.arcade.game.games.moba.buff.Buff;
|
import nautilus.game.arcade.game.games.moba.buff.Buff;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||||
@ -29,13 +30,16 @@ public class BuffPumpkinKing extends Buff<Player>
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static final long DURATION = TimeUnit.MINUTES.toMillis(1);
|
private static final long DURATION = TimeUnit.MINUTES.toMillis(1);
|
||||||
private static final String DAMAGE_REASON = "Pumpkin King Buff";
|
private static final String DAMAGE_REASON = "Boss Buff";
|
||||||
private static final double DAMAGE_FACTOR = 1.5;
|
private static final double DAMAGE_FACTOR = 1.5;
|
||||||
private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN);
|
|
||||||
|
|
||||||
public BuffPumpkinKing(Moba host, Player entity)
|
private final ItemStack _helmet;
|
||||||
|
|
||||||
|
public BuffPumpkinKing(Moba host, Player entity, ItemStack helmet)
|
||||||
{
|
{
|
||||||
super(host, entity, DURATION);
|
super(host, entity, DURATION);
|
||||||
|
|
||||||
|
_helmet = helmet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +48,7 @@ public class BuffPumpkinKing extends Buff<Player>
|
|||||||
_entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1));
|
_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);
|
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.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F);
|
||||||
_entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and 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
|
@Override
|
||||||
@ -61,7 +65,7 @@ public class BuffPumpkinKing extends Buff<Player>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFakeHelmet(_entity, HELMET);
|
sendFakeHelmet(_entity, _helmet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -80,7 +84,7 @@ public class BuffPumpkinKing extends Buff<Player>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL);
|
damagee.getWorld().playEffect(damagee.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
|
||||||
event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR);
|
event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -243,16 +244,9 @@ public class MinionWave implements Listener
|
|||||||
|
|
||||||
private Location targetWither(Minion minion)
|
private Location targetWither(Minion minion)
|
||||||
{
|
{
|
||||||
for (MobaBoss boss : _host.getBossManager().getBosses())
|
for (WitherBoss boss : _host.getBossManager().getWitherBosses())
|
||||||
{
|
{
|
||||||
if (boss.isDead() || !(boss instanceof WitherBoss))
|
if (boss.isDead() || boss.getTeam().equals(_owner))
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
WitherBoss witherBoss = (WitherBoss) boss;
|
|
||||||
|
|
||||||
if (witherBoss.getTeam().equals(_owner))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -352,11 +346,11 @@ public class MinionWave implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MobaBoss> bosses = _host.getBossManager().getBosses();
|
Collection<WitherBoss> bosses = _host.getBossManager().getWitherBosses();
|
||||||
|
|
||||||
for (Minion minion : _minions)
|
for (Minion minion : _minions)
|
||||||
{
|
{
|
||||||
for (MobaBoss boss : bosses)
|
for (WitherBoss boss : bosses)
|
||||||
{
|
{
|
||||||
// Dead, not close enough
|
// Dead, not close enough
|
||||||
if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED)
|
if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED)
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
|
||||||
|
public MobaHeroesValleyMap(Moba host)
|
||||||
|
{
|
||||||
|
super(host);
|
||||||
|
|
||||||
|
new PumpkinBoss(host, host.WorldData.GetDataLocs("BLACK").get(0))
|
||||||
|
.registerBoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package nautilus.game.arcade.game.games.moba.modes;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.games.moba.Moba;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class MobaMap implements Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
protected final Moba _host;
|
||||||
|
|
||||||
|
public MobaMap(Moba host)
|
||||||
|
{
|
||||||
|
_host = host;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public enum MobaMapType
|
||||||
|
{
|
||||||
|
|
||||||
|
HEROES_VALLEY("Heroes Valley", MobaHeroesValleyMap.class),
|
||||||
|
MONOCHROME("Monochrome", MobaMonochromeMap.class)
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String _name;
|
||||||
|
private final Class<? extends MobaMap> _clazz;
|
||||||
|
|
||||||
|
MobaMapType(String name, Class<? extends MobaMap> clazz)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
_clazz = clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MobaMap createInstance(Moba host)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _clazz.getConstructor(Moba.class).newInstance(host);
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,225 @@
|
|||||||
|
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.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;
|
||||||
|
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.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.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
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.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class MobaMonochromeMap extends MobaMap
|
||||||
|
{
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
private boolean _active;
|
||||||
|
private long _lastStart;
|
||||||
|
|
||||||
|
public MobaMonochromeMap(Moba host)
|
||||||
|
{
|
||||||
|
super(host);
|
||||||
|
|
||||||
|
_skeletons = new HashSet<>();
|
||||||
|
_killedSkeletons = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void live(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Live)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastStart = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void updateStart(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST || !_host.IsLive() || _active || !UtilTime.elapsed(_lastStart, START_TIME))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastStart = System.currentTimeMillis();
|
||||||
|
_active = true;
|
||||||
|
|
||||||
|
UtilTextMiddle.display(C.cRedB + "Wither Skeletons", "Have Spawned!", 10, 40, 10);
|
||||||
|
_host.Announce(F.main("Game", F.elem("Wither Skeletons") + " have spawned! The team that kills the most within " + F.time("30 seconds") + " receives a buff!"), false);
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void updateEnd(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST || !_host.IsLive() || !_active || !UtilTime.elapsed(_lastStart, ACTIVE_TIME))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
if (redKills == blueKills)
|
||||||
|
{
|
||||||
|
winners = Arrays.asList(red, blue);
|
||||||
|
}
|
||||||
|
// Red win
|
||||||
|
else if (redKills > blueKills)
|
||||||
|
{
|
||||||
|
winners = Collections.singletonList(red);
|
||||||
|
}
|
||||||
|
// Blue win
|
||||||
|
else
|
||||||
|
{
|
||||||
|
winners = Collections.singletonList(blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give the team members the buff
|
||||||
|
BuffManager buffManager = _host.getBuffManager();
|
||||||
|
winners.forEach(team ->
|
||||||
|
{
|
||||||
|
for (Player teamMember : team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
buffManager.apply(new BuffPumpkinKing(_host, teamMember, BUFF_HELMET));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
|
public void entityDeath(EntityDeathEvent event)
|
||||||
|
{
|
||||||
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
|
if (_skeletons.remove(entity))
|
||||||
|
{
|
||||||
|
Player player = entity.getKiller();
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTeam team = _host.GetTeam(player);
|
||||||
|
|
||||||
|
if (team == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getDrops().clear();
|
||||||
|
event.setDroppedExp(0);
|
||||||
|
_killedSkeletons.put(team, _killedSkeletons.get(team) + 1);
|
||||||
|
player.sendMessage(F.main("Game", "You killed a " + F.name("Wither Skeleton") + "!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void entityCombust(EntityCombustEvent event)
|
||||||
|
{
|
||||||
|
if (_skeletons.contains(event.getEntity()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -49,12 +49,9 @@ public class OvertimeManager implements Listener
|
|||||||
UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!");
|
UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!");
|
||||||
_host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false);
|
_host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false);
|
||||||
|
|
||||||
for (MobaBoss boss : _host.getBossManager().getBosses())
|
for (WitherBoss boss : _host.getBossManager().getWitherBosses())
|
||||||
{
|
{
|
||||||
if (boss instanceof WitherBoss)
|
boss.setDamageable(true);
|
||||||
{
|
|
||||||
((WitherBoss) boss).setDamageable(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package nautilus.game.arcade.game.games.moba.progression;
|
||||||
|
|
||||||
|
public class MobaLevelData
|
||||||
|
{
|
||||||
|
|
||||||
|
private final int _exp;
|
||||||
|
private final int _level;
|
||||||
|
private final int _thisLevel;
|
||||||
|
private final int _nextLevel;
|
||||||
|
|
||||||
|
public MobaLevelData(long exp)
|
||||||
|
{
|
||||||
|
_exp = (int) exp;
|
||||||
|
_level = MobaProgression.getLevel(exp);
|
||||||
|
_thisLevel = MobaProgression.getExpFor(_level);
|
||||||
|
_nextLevel = MobaProgression.getExpFor(_level + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExp()
|
||||||
|
{
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel()
|
||||||
|
{
|
||||||
|
return _level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpThisLevel()
|
||||||
|
{
|
||||||
|
return _thisLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpJustThisLevel()
|
||||||
|
{
|
||||||
|
return _nextLevel - _thisLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpReminder()
|
||||||
|
{
|
||||||
|
return _nextLevel - _exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPercentageComplete()
|
||||||
|
{
|
||||||
|
return (double) (_exp - _thisLevel) / (double) (getExpJustThisLevel());
|
||||||
|
}
|
||||||
|
}
|
@ -40,20 +40,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
public class MobaProgression implements Listener
|
public class MobaProgression implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final int[] EXP_LEVELS;
|
|
||||||
private static final int EXP_PER_LEVEL = 1000;
|
private static final int EXP_PER_LEVEL = 1000;
|
||||||
private static final int EXP_FACTOR = 3;
|
private static final int EXP_FACTOR = 3;
|
||||||
public static final DecimalFormat FORMAT = new DecimalFormat("0.0");
|
public static final DecimalFormat FORMAT = new DecimalFormat("0.0");
|
||||||
|
|
||||||
static
|
public static int getExpFor(int level)
|
||||||
{
|
{
|
||||||
EXP_LEVELS = new int[100];
|
return EXP_PER_LEVEL * (level - 1);
|
||||||
int expRequired = EXP_PER_LEVEL;
|
}
|
||||||
|
|
||||||
for (int level = 0; level < 100; level++)
|
public static int getLevel(long exp)
|
||||||
{
|
{
|
||||||
EXP_LEVELS[level] = expRequired += EXP_PER_LEVEL;
|
return (int) Math.floor(exp / EXP_PER_LEVEL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Moba _host;
|
private final Moba _host;
|
||||||
@ -84,7 +82,7 @@ public class MobaProgression implements Listener
|
|||||||
public void Execute(Player caller, String[] args)
|
public void Execute(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
MobaRole role = MobaRole.valueOf(args[0].toUpperCase());
|
MobaRole role = MobaRole.valueOf(args[0].toUpperCase());
|
||||||
int exp = getExperience(Integer.parseInt(args[1])) - 1;
|
int exp = getExpFor(Integer.parseInt(args[1])) - 1;
|
||||||
_host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp);
|
_host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp);
|
||||||
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + "."));
|
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + "."));
|
||||||
}
|
}
|
||||||
@ -176,32 +174,12 @@ public class MobaProgression implements Listener
|
|||||||
_host.GetPlayers(true).forEach(this::rewardPlayer);
|
_host.GetPlayers(true).forEach(this::rewardPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExperience(int level)
|
|
||||||
{
|
|
||||||
if (level > EXP_LEVELS.length)
|
|
||||||
{
|
|
||||||
return Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
else if (level < 1)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXP_LEVELS[level - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getExperience(Player player, MobaRole role)
|
public long getExperience(Player player, MobaRole role)
|
||||||
{
|
{
|
||||||
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
|
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
|
||||||
return _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat);
|
return _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getExperienceCurrentLevel(Player player, MobaRole role)
|
|
||||||
{
|
|
||||||
int level = getLevel(player, role);
|
|
||||||
return getExperience(level) - getExperience(level - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel(Player player, HeroKit kit)
|
public int getLevel(Player player, HeroKit kit)
|
||||||
{
|
{
|
||||||
return getLevel(player, kit.getRole());
|
return getLevel(player, kit.getRole());
|
||||||
@ -212,28 +190,25 @@ public class MobaProgression implements Listener
|
|||||||
return getLevel(getExperience(player, role));
|
return getLevel(getExperience(player, role));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLevel(long exp)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (int expRequired : EXP_LEVELS)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if (expRequired > exp)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rewardPlayer(Player player)
|
private void rewardPlayer(Player player)
|
||||||
{
|
{
|
||||||
MobaPlayer mobaPlayer = _host.getMobaData(player);
|
MobaPlayer mobaPlayer = _host.getMobaData(player);
|
||||||
|
|
||||||
|
if (mobaPlayer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MobaRole role = mobaPlayer.getRole();
|
MobaRole role = mobaPlayer.getRole();
|
||||||
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
|
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
|
||||||
long currentExp = _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat);
|
// EXP before earning
|
||||||
|
long currentExp = getExperience(player, role);
|
||||||
|
// Level before earning
|
||||||
|
int currentLevel = getLevel(currentExp);
|
||||||
|
|
||||||
|
player.sendMessage("currentExp = " + currentExp);
|
||||||
|
player.sendMessage("currentLevel = " + currentLevel);
|
||||||
|
|
||||||
AtomicInteger earnedExp = new AtomicInteger();
|
AtomicInteger earnedExp = new AtomicInteger();
|
||||||
|
|
||||||
for (GemData data : _host.GetGems(player).values())
|
for (GemData data : _host.GetGems(player).values())
|
||||||
@ -242,16 +217,16 @@ public class MobaProgression implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR);
|
earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR);
|
||||||
|
MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get());
|
||||||
|
|
||||||
int level = getLevel(currentExp);
|
player.sendMessage("exp = " + levelData.getExp());
|
||||||
int newLevel = getLevel(currentExp + earnedExp.get());
|
player.sendMessage("level = " + levelData.getLevel());
|
||||||
long expForThisLevel = getExperienceCurrentLevel(player, role);
|
player.sendMessage("thisLevel = " + levelData.getExpThisLevel());
|
||||||
AtomicBoolean levelUp = new AtomicBoolean();
|
player.sendMessage("justThisLevel = " + levelData.getExpJustThisLevel());
|
||||||
|
player.sendMessage("reminder = " + levelData.getExpReminder());
|
||||||
|
player.sendMessage("percentage = " + levelData.getPercentageComplete());
|
||||||
|
|
||||||
if (newLevel > level)
|
AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel);
|
||||||
{
|
|
||||||
levelUp.set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get());
|
_host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get());
|
||||||
|
|
||||||
@ -262,8 +237,8 @@ public class MobaProgression implements Listener
|
|||||||
|
|
||||||
player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : ""));
|
player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : ""));
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
player.sendMessage(MobaUtil.getProgressBar(currentExp, currentExp + earnedExp.get(), expForThisLevel, 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + expForThisLevel);
|
player.sendMessage(MobaUtil.getProgressBar(currentExp, levelData.getExp(), levelData.getExpThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel());
|
||||||
player.sendMessage(C.cGreen + FORMAT.format((currentExp + earnedExp.get()) / (double) expForThisLevel * 100D) + C.cWhite + "% complete for Level " + level);
|
player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D) + C.cWhite + "% complete for Level " + currentLevel));
|
||||||
|
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
player.sendMessage(ArcadeFormat.Line);
|
player.sendMessage(ArcadeFormat.Line);
|
||||||
@ -272,7 +247,7 @@ public class MobaProgression implements Listener
|
|||||||
{
|
{
|
||||||
for (HeroKit kit : _host.getKits())
|
for (HeroKit kit : _host.getKits())
|
||||||
{
|
{
|
||||||
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != newLevel)
|
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getLevel())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import nautilus.game.arcade.ArcadeManager;
|
|||||||
import nautilus.game.arcade.game.games.moba.Moba;
|
import nautilus.game.arcade.game.games.moba.Moba;
|
||||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
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.HeroKit;
|
||||||
|
import nautilus.game.arcade.game.games.moba.progression.MobaLevelData;
|
||||||
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
||||||
import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation;
|
import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -49,11 +50,7 @@ public class MobaRolePage extends ShopPageBase<ArcadeManager, MobaRoleShop>
|
|||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
int level = _host.getProgression().getLevel(_player, _role);
|
MobaLevelData levelData = new MobaLevelData(_host.getProgression().getExperience(_player, _role));
|
||||||
long currentExp = _host.getProgression().getExperience(_player, _role);
|
|
||||||
long thisLevel = _host.getProgression().getExperienceCurrentLevel(_player, _role);
|
|
||||||
long toNextLevel = _host.getProgression().getExperience(level) - currentExp;
|
|
||||||
long levelExp = _host.getProgression().getExperience(level);
|
|
||||||
|
|
||||||
addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull())
|
addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull())
|
||||||
.setTitle(_role.getChatColor() + _role.getName())
|
.setTitle(_role.getChatColor() + _role.getName())
|
||||||
@ -62,8 +59,8 @@ public class MobaRolePage extends ShopPageBase<ArcadeManager, MobaRoleShop>
|
|||||||
"Every " + F.elem(10) + " levels you unlock a new",
|
"Every " + F.elem(10) + " levels you unlock a new",
|
||||||
"hero within the " + F.name(_role.getName()) + " category.",
|
"hero within the " + F.name(_role.getName()) + " category.",
|
||||||
"",
|
"",
|
||||||
"Your Level: " + C.cGreen + level,
|
"Your Level: " + C.cGreen + levelData.getLevel(),
|
||||||
"Next Level: " + C.cGreen + toNextLevel + C.cGray + "/" + C.cGreen + thisLevel + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(100 - ((double) currentExp / (double) levelExp) * 100D) + C.cGray + "%)"
|
"Next Level: " + C.cGreen + levelData.getExpReminder() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)"
|
||||||
)
|
)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user