Gotta go fast!
This commit is contained in:
parent
3210843395
commit
a32ae91996
File diff suppressed because it is too large
Load Diff
|
@ -257,7 +257,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||
public int HealthSet = -1;
|
||||
|
||||
public boolean SpawnTeleport = true;
|
||||
public boolean PrepareFreeze = true;
|
||||
|
||||
private double _itemMergeRadius = 0;
|
||||
|
||||
|
@ -293,7 +292,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||
|
||||
public boolean AllowParticles = true;
|
||||
|
||||
public boolean Prepare = true;
|
||||
public long PrepareTime = 9000;
|
||||
public boolean PrepareFreeze = true;
|
||||
public boolean PlaySoundGameStart = true;
|
||||
|
||||
public double XpMult = 1;
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
package nautilus.game.arcade.game.games.moba;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.moba.kit.KitPlayer;
|
||||
import nautilus.game.arcade.game.games.moba.kit.PregameSelection;
|
||||
import nautilus.game.arcade.game.games.moba.recall.Recall;
|
||||
import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint;
|
||||
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class Moba extends TeamGame
|
||||
{
|
||||
|
@ -22,13 +31,20 @@ public class Moba extends TeamGame
|
|||
};
|
||||
|
||||
private final List<CapturePoint> _capturePoints = new ArrayList<>(3);
|
||||
private final List<Tower> _towers = new ArrayList<>(12);
|
||||
|
||||
private final Map<Player, MobaRole> _roles = new HashMap<>();
|
||||
|
||||
private final Set<Listener> _listeners = new HashSet<>();
|
||||
|
||||
public Moba(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION);
|
||||
|
||||
//Prepare = false;
|
||||
PrepareFreeze = false;
|
||||
DeathOut = false;
|
||||
DeathSpectateSecs = 8;
|
||||
DeathSpectateSecs = 10;
|
||||
HungerSet = 20;
|
||||
DontAllowOverfill = false;
|
||||
|
||||
|
@ -37,6 +53,12 @@ public class Moba extends TeamGame
|
|||
.setGiveCompassToSpecs(true)
|
||||
.setGiveCompassToAlive(false)
|
||||
.register(this);
|
||||
|
||||
Listener preGameSelection = new PregameSelection(this, null);
|
||||
_listeners.add(preGameSelection);
|
||||
|
||||
Listener recall = new Recall(this);
|
||||
_listeners.add(recall);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +70,60 @@ public class Moba extends TeamGame
|
|||
{
|
||||
_capturePoints.add(new CapturePoint(this, location));
|
||||
}
|
||||
|
||||
Map<String, Location> towers = getLocationStartsWith("TOWER");
|
||||
|
||||
for (Entry<String, Location> entry : towers.entrySet())
|
||||
{
|
||||
String key = entry.getKey();
|
||||
Location location = entry.getValue();
|
||||
String[] components = key.split(" ");
|
||||
|
||||
if (components.length < 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String team = components[1];
|
||||
String lane = components[2];
|
||||
int laneInt = 0;
|
||||
|
||||
switch (lane)
|
||||
{
|
||||
case "A":
|
||||
laneInt = 0;
|
||||
break;
|
||||
case "B":
|
||||
laneInt = 1;
|
||||
break;
|
||||
case "C":
|
||||
laneInt = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
boolean firstTower;
|
||||
|
||||
try
|
||||
{
|
||||
firstTower = Integer.parseInt(components[3]) == 1;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int health = 1000;
|
||||
GameTeam gameTeam = getTeam(team);
|
||||
|
||||
if (gameTeam == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_towers.add(new Tower(this, location, gameTeam, laneInt, health, firstTower));
|
||||
}
|
||||
|
||||
_listeners.forEach(UtilServer::RegisterEvents);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,6 +148,8 @@ public class Moba extends TeamGame
|
|||
case End:
|
||||
writeEnd();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
Scoreboard.draw();
|
||||
|
@ -92,6 +170,37 @@ public class Moba extends TeamGame
|
|||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void prepare(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Tower tower : _towers)
|
||||
{
|
||||
tower.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void live(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
super.disable();
|
||||
_listeners.forEach(UtilServer::Unregister);
|
||||
_listeners.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
|
@ -120,4 +229,17 @@ public class Moba extends TeamGame
|
|||
|
||||
return map;
|
||||
}
|
||||
|
||||
private GameTeam getTeam(String name)
|
||||
{
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (team.GetName().equals(name))
|
||||
{
|
||||
return team;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,22 +1,25 @@
|
|||
package nautilus.game.arcade.game.games.moba;
|
||||
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import org.bukkit.Color;
|
||||
|
||||
public enum MobaRole
|
||||
{
|
||||
|
||||
ASSASSIN("Assassin", null),
|
||||
HUNTER("Hunter", null),
|
||||
MAGE("Mage", null),
|
||||
WARRIOR("Warrior", null),
|
||||
ASSASSIN("Assassin", Color.BLUE, null),
|
||||
HUNTER("Hunter", Color.LIME, null),
|
||||
MAGE("Mage", Color.RED, null),
|
||||
WARRIOR("Warrior", Color.YELLOW, null),
|
||||
;
|
||||
|
||||
private String _name;
|
||||
private Color _color;
|
||||
private Kit[] _kits;
|
||||
|
||||
MobaRole(String name, Kit[] kits)
|
||||
MobaRole(String name, Color color, Kit[] kits)
|
||||
{
|
||||
_name = name;
|
||||
_color = color;
|
||||
_kits = kits;
|
||||
}
|
||||
|
||||
|
@ -25,6 +28,11 @@ public enum MobaRole
|
|||
return _name;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public Kit[] getKits()
|
||||
{
|
||||
return _kits;
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
package nautilus.game.arcade.game.games.moba.kit;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class HeroKit extends Kit
|
||||
{
|
||||
|
||||
private final MobaRole _role;
|
||||
|
||||
private static final int AMMO_SLOT = 7;
|
||||
private ItemStack _ammo;
|
||||
private long _giveTime;
|
||||
private int _maxAmmo;
|
||||
|
||||
private static final int RECALL_SLOT = 8;
|
||||
private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED)
|
||||
.setTitle(C.cGreenB + "Recall to you Base")
|
||||
.addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel your teleport.")
|
||||
.build();
|
||||
|
||||
public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role)
|
||||
{
|
||||
super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand);
|
||||
|
||||
_role = role;
|
||||
}
|
||||
|
||||
public MobaRole getRole()
|
||||
{
|
||||
return _role;
|
||||
}
|
||||
|
||||
public void setAmmo(ItemStack ammo, long giveTime)
|
||||
{
|
||||
_ammo = ammo;
|
||||
_giveTime = giveTime;
|
||||
}
|
||||
|
||||
public void setMaxAmmo(int max)
|
||||
{
|
||||
_maxAmmo = max;
|
||||
}
|
||||
|
||||
protected boolean useAmmo(Player player, int amount)
|
||||
{
|
||||
ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT);
|
||||
|
||||
if (itemStack == null || itemStack.getAmount() < amount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
itemStack.setAmount(itemStack.getAmount() - amount);
|
||||
player.updateInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveAmmo(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK || Manager.GetGame() == null || !Manager.GetGame().IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if (!HasKit(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT);
|
||||
long giveTime = _giveTime;
|
||||
|
||||
//TODO shop cooldown reduction
|
||||
|
||||
if (!Recharge.Instance.use(player, "Ammo", giveTime, false, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
itemStack = _ammo;
|
||||
player.getInventory().setItem(AMMO_SLOT, itemStack);
|
||||
player.updateInventory();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStack.getAmount() >= _maxAmmo)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
itemStack.setAmount(itemStack.getAmount() + 1);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
inventory.setItem(AMMO_SLOT, _ammo);
|
||||
inventory.setItem(RECALL_SLOT, RECALL_ITEM);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package nautilus.game.arcade.game.games.moba.kit;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class KitSelection implements Listener
|
||||
{
|
||||
|
||||
private final
|
||||
|
||||
public KitSelection(Moba moba)
|
||||
{
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void live(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package nautilus.game.arcade.game.games.moba.kit;
|
||||
|
||||
import mineplex.core.common.entity.ClientArmorStand;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilSkull;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler.ListenerPriority;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
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.MobaRole;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class PregameSelection implements Listener, IPacketHandler
|
||||
{
|
||||
|
||||
private final Moba _host;
|
||||
private final Kit[] _kits;
|
||||
private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>();
|
||||
|
||||
public PregameSelection(Moba host, Kit[] kits)
|
||||
{
|
||||
_host = host;
|
||||
_kits = kits;
|
||||
|
||||
_host.getArcadeManager().getPacketHandler().addPacketHandler(this, ListenerPriority.NORMAL, true, PacketPlayInUseEntity.class);
|
||||
}
|
||||
|
||||
// Setup
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void prepare(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (GameTeam team : _host.GetTeamList())
|
||||
{
|
||||
if (team.GetColor() == ChatColor.RED)
|
||||
{
|
||||
spawnRoleUI(team, "PINK");
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnRoleUI(team, "PURPLE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnRoleUI(GameTeam team, String dataKey)
|
||||
{
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
List<Location> spawns = _host.WorldData.GetDataLocs(dataKey);
|
||||
Location average = UtilAlg.getAverageLocation(team.GetSpawns());
|
||||
Player[] players = team.GetPlayers(true).toArray(new Player[0]);
|
||||
|
||||
ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 3).build();
|
||||
|
||||
UtilServer.runSyncLater(() ->
|
||||
{
|
||||
for (Location location : spawns)
|
||||
{
|
||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average)));
|
||||
|
||||
MobaRole role = MobaRole.values()[i.getAndIncrement()];
|
||||
ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players);
|
||||
|
||||
stand.setCustomNameVisible(true);
|
||||
stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE");
|
||||
stand.setArms(true);
|
||||
stand.setHelmet(head);
|
||||
stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role));
|
||||
stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role));
|
||||
stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role));
|
||||
|
||||
_roleStands.put(stand, role);
|
||||
}
|
||||
}, 5);
|
||||
}
|
||||
|
||||
private Location prepareLocation(Location location)
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
|
||||
block.setType(Material.SMOOTH_BRICK);
|
||||
block.setData((byte) 3);
|
||||
|
||||
return location.clone().add(0, 1, 0);
|
||||
}
|
||||
|
||||
private ItemStack buildColouredStack(Material material, MobaRole role)
|
||||
{
|
||||
return new ItemBuilder(material).setColor(role.getColor()).build();
|
||||
}
|
||||
|
||||
// Listen for those packety clicks
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket();
|
||||
Player player = packetInfo.getPlayer();
|
||||
int entityId = packet.a;
|
||||
|
||||
for (ClientArmorStand stand : _roleStands.keySet())
|
||||
{
|
||||
if (stand.getEntityId() != entityId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("Beep beep I'm an amourstand, I said beep beep I have an id of " + entityId);
|
||||
|
||||
packetInfo.setCancelled(true);
|
||||
|
||||
MobaRole role = _roleStands.get(stand);
|
||||
RoleSelectEvent event = new RoleSelectEvent(player, stand, role);
|
||||
UtilServer.CallEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (ClientArmorStand stand2 : _roleStands.keySet())
|
||||
{
|
||||
stand2.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unregister
|
||||
@EventHandler
|
||||
public void live(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_host.getArcadeManager().getPacketHandler().removePacketHandler(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package nautilus.game.arcade.game.games.moba.kit;
|
||||
|
||||
import mineplex.core.common.entity.ClientArmorStand;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class RoleSelectEvent extends PlayerEvent implements Cancellable
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private final ClientArmorStand _stand;
|
||||
private final MobaRole _role;
|
||||
|
||||
private boolean _cancel;
|
||||
|
||||
public RoleSelectEvent(Player who, ClientArmorStand stand, MobaRole role)
|
||||
{
|
||||
super(who);
|
||||
|
||||
_stand = stand;
|
||||
_role = role;
|
||||
}
|
||||
|
||||
public ClientArmorStand getStand()
|
||||
{
|
||||
return _stand;
|
||||
}
|
||||
|
||||
public MobaRole getRole()
|
||||
{
|
||||
return _role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b)
|
||||
{
|
||||
_cancel = b;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package nautilus.game.arcade.game.games.moba.kit.heroes;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HeroHattori extends HeroKit
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION = {
|
||||
"Something something"
|
||||
};
|
||||
|
||||
private static final Perk[] PERKS = {
|
||||
new PerkDoubleJump("Double Jump", 1, 1, true)
|
||||
};
|
||||
|
||||
private static final ItemStack[] PLAYER_ITEMS = {
|
||||
new ItemStack(Material.WOOD_SWORD),
|
||||
};
|
||||
|
||||
private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR);
|
||||
|
||||
public HeroHattori(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package nautilus.game.arcade.game.games.moba.recall;
|
||||
|
||||
import com.sun.org.apache.regexp.internal.RE;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jooq.util.derby.sys.Sys;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Recall implements Listener
|
||||
{
|
||||
|
||||
private static final int RECALL_TIME = 5000;
|
||||
private static final double PARTICLE_HEIGHT = 2.5;
|
||||
private static final double PARTICLE_RADIUS = 2.5;
|
||||
|
||||
private final Moba _host;
|
||||
|
||||
private final Set<RecallSession> _sessions;
|
||||
|
||||
public Recall(Moba host)
|
||||
{
|
||||
_host = host;
|
||||
|
||||
_sessions = new HashSet<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void interactBed(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
if (itemStack == null || itemStack.getType() != Material.BED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sessions.add(new RecallSession(player));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
{
|
||||
if (!_lastRecallStart.containsKey(player.getUniqueId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
long start = _lastRecallStart.get(player.getUniqueId());
|
||||
|
||||
if (UtilTime.elapsed(start, RECALL_TIME))
|
||||
{
|
||||
_host.GetTeam(player).SpawnTeleport(player);
|
||||
_lastRecallStart.remove(player.getUniqueId());
|
||||
}
|
||||
else
|
||||
{
|
||||
Location location = player.getLocation().add(0, 0.25, 0);
|
||||
double height = (now - start) / RECALL_TIME;
|
||||
|
||||
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10)
|
||||
{
|
||||
double x = PARTICLE_RADIUS * Math.sin(theta);
|
||||
double z = PARTICLE_RADIUS * Math.cos(theta);
|
||||
|
||||
for (int y = 0; y < height * PARTICLE_HEIGHT; y += 0.5)
|
||||
{
|
||||
location.add(x, y, z);
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG);
|
||||
|
||||
location.subtract(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void damage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageePlayer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecallSession session =
|
||||
}
|
||||
|
||||
public RecallSession getSession(Player player)
|
||||
{
|
||||
for (RecallSession session : _sessions)
|
||||
{
|
||||
if (session.Player.equals(player))
|
||||
{
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package nautilus.game.arcade.game.games.moba.recall;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class RecallSession
|
||||
{
|
||||
|
||||
public Player Player;
|
||||
public long Start;
|
||||
public Location Location;
|
||||
|
||||
public RecallSession(Player player)
|
||||
{
|
||||
Player = player;
|
||||
Start = System.currentTimeMillis();
|
||||
Location = player.getLocation();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package nautilus.game.arcade.game.games.moba.shop;
|
||||
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class MobaShop implements Listener
|
||||
{
|
||||
|
||||
private final Moba _host;
|
||||
|
||||
public MobaShop(Moba host)
|
||||
{
|
||||
_host = host;
|
||||
}
|
||||
}
|
|
@ -178,8 +178,6 @@ public class CapturePoint
|
|||
|
||||
private void display(GameTeam team, boolean forward)
|
||||
{
|
||||
Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward);
|
||||
|
||||
double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1;
|
||||
int changed = 0;
|
||||
for (Block block : _wool)
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package nautilus.game.arcade.game.games.moba.structure.tower;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
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.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.utils.UtilVariant;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Guardian;
|
||||
|
||||
public class Tower
|
||||
{
|
||||
|
||||
private final Moba _host;
|
||||
private final Location _location;
|
||||
private final GameTeam _team;
|
||||
private int _lane;
|
||||
private double _health;
|
||||
private int _maxHealth;
|
||||
private boolean _firstTower;
|
||||
private Guardian _guardian;
|
||||
private boolean _dead;
|
||||
|
||||
public Tower(Moba host, Location location, GameTeam team, int lane, int health, boolean firstTower)
|
||||
{
|
||||
_host = host;
|
||||
_location = location;
|
||||
_team = team;
|
||||
_lane = lane;
|
||||
_health = health;
|
||||
_maxHealth = health;
|
||||
_firstTower = firstTower;
|
||||
}
|
||||
|
||||
public void setup()
|
||||
{
|
||||
if (_firstTower)
|
||||
{
|
||||
_guardian = _location.getWorld().spawn(_location, Guardian.class);
|
||||
}
|
||||
else
|
||||
{
|
||||
_guardian = UtilVariant.spawnElderGuardian(_location);
|
||||
}
|
||||
|
||||
_guardian.setCustomNameVisible(true);
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
public void updateTarget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void damage(double damage)
|
||||
{
|
||||
_health -= damage;
|
||||
|
||||
if (_health <= 0)
|
||||
{
|
||||
UtilServer.CallEvent(new TowerDestroyEvent(this));
|
||||
_dead = true;
|
||||
_guardian.remove();
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
float percentage = (float) _health / (float) _maxHealth;
|
||||
|
||||
_guardian.setCustomName(UtilTextMiddle.progress(percentage));
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
_host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 4, 0), 4), _location, false);
|
||||
_location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG);
|
||||
}
|
||||
|
||||
public boolean isDead()
|
||||
{
|
||||
return _dead;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package nautilus.game.arcade.game.games.moba.structure.tower;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class TowerDestroyEvent extends Event
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private Tower _tower;
|
||||
|
||||
public TowerDestroyEvent(Tower tower)
|
||||
{
|
||||
_tower = tower;
|
||||
}
|
||||
|
||||
public Tower getTower()
|
||||
{
|
||||
return _tower;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
|
@ -211,6 +211,8 @@ public abstract class UHC extends Game
|
|||
|
||||
_state = UHCState.SAFE;
|
||||
|
||||
Prepare = false;
|
||||
|
||||
HideTeamSheep = true;
|
||||
|
||||
StrictAntiHack = true;
|
||||
|
|
|
@ -104,7 +104,7 @@ public class GameHostManager implements Listener
|
|||
ultraGames.add(GameType.MonsterMaze);
|
||||
ultraGames.add(GameType.Gladiators);
|
||||
|
||||
//Hero Games
|
||||
//HeroKit Games
|
||||
heroGames.add(GameType.ChampionsDominate);
|
||||
heroGames.add(GameType.ChampionsTDM);
|
||||
heroGames.add(GameType.ChampionsCTF);
|
||||
|
|
|
@ -636,7 +636,7 @@ public class GameManager implements Listener
|
|||
return;
|
||||
|
||||
// Sir, I'll handle this.
|
||||
if (game instanceof UHC)
|
||||
if (!game.Prepare)
|
||||
return;
|
||||
|
||||
final ArrayList<Player> players = game.GetPlayers(true);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ServerResetCommand extends CommandBase<ServerReset>
|
|||
clientEvent.GetClient().Game().SetEconomyBalance(0);
|
||||
}
|
||||
|
||||
File economyDir = new File("economy/");
|
||||
File economyDir = new File("shop/");
|
||||
|
||||
FilenameFilter statsFilter = new FilenameFilter()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue