Fixing arena moving
This commit is contained in:
parent
4e2a422f27
commit
f8f95c64e5
@ -770,6 +770,8 @@ public enum Achievement
|
||||
new String[]{"Get hit by a monster and", "land on the Safe Pad"},
|
||||
new int[]{1},
|
||||
AchievementCategory.MONSTER_MAZE),
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
@ -150,6 +150,10 @@ public enum AchievementCategory
|
||||
MONSTER_MAZE("Monster Maze", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
|
||||
Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM"),
|
||||
|
||||
GLADIATORS("Gladiators", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.IRON_SWORD, 0, GameCategory.ARCADE, null)
|
||||
|
||||
;
|
||||
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
@ -27,6 +26,9 @@ public class Arena
|
||||
private boolean _isUsed;
|
||||
|
||||
private ArrayList<Location> _doorBlocks;
|
||||
private boolean _isOpenDoor;
|
||||
|
||||
private ArrayList<Player> _pastPlayers;
|
||||
|
||||
public Arena(Gladiators host, Location mid, ArenaType colour)
|
||||
{
|
||||
@ -37,6 +39,8 @@ public class Arena
|
||||
_parent = null;
|
||||
_isUsed = false;
|
||||
_doorBlocks = new ArrayList<>();
|
||||
_isOpenDoor = false;
|
||||
_pastPlayers = new ArrayList<>();
|
||||
|
||||
setupSpawns();
|
||||
}
|
||||
@ -174,30 +178,9 @@ public class Arena
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ArrayList<Player> getPlayers()
|
||||
public ArrayList<Player> getPastPlayers()
|
||||
{
|
||||
ArrayList<Player> pls = new ArrayList<>();
|
||||
|
||||
for (Player p : _host.GetPlayers(true))
|
||||
{
|
||||
if (UtilMath.offset(p.getLocation(), _mid) <= 21)
|
||||
pls.add(p);
|
||||
}
|
||||
|
||||
return pls;
|
||||
}
|
||||
|
||||
public int getPlayerCount()
|
||||
{
|
||||
ArrayList<Player> pls = new ArrayList<>();
|
||||
|
||||
for (Player p : _host.GetPlayers(true))
|
||||
{
|
||||
if (UtilMath.offset(p.getLocation(), _mid) <= 21)
|
||||
pls.add(p);
|
||||
}
|
||||
|
||||
return pls.size();
|
||||
return _pastPlayers;
|
||||
}
|
||||
|
||||
public boolean isUsed()
|
||||
@ -215,4 +198,23 @@ public class Arena
|
||||
for (Location loc : _doorBlocks)
|
||||
loc.getBlock().setType(Material.OBSIDIAN);
|
||||
}
|
||||
|
||||
public boolean isOpenDoor()
|
||||
{
|
||||
return _isOpenDoor;
|
||||
}
|
||||
|
||||
public void openDoor()
|
||||
{
|
||||
_isOpenDoor = true;
|
||||
|
||||
_host.Manager.getScheduler().scheduleSyncDelayedTask(_host.Manager.getPlugin(), () -> {
|
||||
|
||||
for (Location loc : _doorBlocks)
|
||||
{
|
||||
loc.getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
}, 5L);
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
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;
|
||||
@ -36,7 +38,10 @@ public class Gladiators extends SoloGame
|
||||
public Gladiators(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Gladiators,
|
||||
new Kit[0],
|
||||
new Kit[]
|
||||
{
|
||||
new KitGladiator(manager)
|
||||
},
|
||||
new String[]
|
||||
{
|
||||
"This is a 1v1 tournament!",
|
||||
@ -51,8 +56,6 @@ public class Gladiators extends SoloGame
|
||||
DamageTeamSelf = true;
|
||||
HungerSet = 20;
|
||||
|
||||
setKits(new Kit[]{new KitGladiator(manager)});
|
||||
|
||||
_playerArenas = new HashMap<>();
|
||||
}
|
||||
|
||||
@ -277,11 +280,11 @@ public class Gladiators extends SoloGame
|
||||
{
|
||||
for (Player p : GetPlayers(true))
|
||||
{
|
||||
for (Arena a : _allArenas)
|
||||
{
|
||||
if (a.getPlayers().contains(p))
|
||||
_playerArenas.put(p, a);
|
||||
}
|
||||
Location closest = UtilAlg.findClosest(p.getLocation(), getAllArenaMids());
|
||||
Arena arena = getArenaByMid(closest);
|
||||
_playerArenas.put(p, arena);
|
||||
|
||||
giveLoadout(p, _playerArenas.get(p).getColour());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -300,17 +303,20 @@ public class Gladiators extends SoloGame
|
||||
if (!_playerArenas.containsKey(e.getPlayer()))
|
||||
return;
|
||||
|
||||
for (Arena a : _allArenas)
|
||||
for (Player p : GetPlayers(true))
|
||||
{
|
||||
if (a.getPlayers().contains(e.getPlayer()))
|
||||
{
|
||||
if (_playerArenas.get(e.getPlayer()) != a)
|
||||
{
|
||||
Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(),
|
||||
a, _playerArenas.get(e.getPlayer())));
|
||||
if (!_playerArenas.containsKey(p))
|
||||
continue;
|
||||
|
||||
_playerArenas.put(e.getPlayer(), a);
|
||||
}
|
||||
if (!_playerArenas.get(p).isOpenDoor())
|
||||
continue; // No need to check since no door to go through.
|
||||
|
||||
Arena closest = getArenaByMid(UtilAlg.findClosest(p.getLocation(), getAllArenaMids()));
|
||||
|
||||
if (closest != _playerArenas.get(p))
|
||||
{
|
||||
Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), closest, _playerArenas.get(p)));
|
||||
_playerArenas.put(p, closest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,7 +329,65 @@ public class Gladiators extends SoloGame
|
||||
Arena current = e.getTo();
|
||||
|
||||
old.closeDoor();
|
||||
old.getPastPlayers().remove(p);
|
||||
current.getPastPlayers().add(p);
|
||||
|
||||
p.sendMessage("§7§lDEBUG: §3You left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3.");
|
||||
|
||||
giveLoadout(p, current.getColour());
|
||||
|
||||
}
|
||||
|
||||
private void giveLoadout(Player p, ArenaType type)
|
||||
{
|
||||
if (!GetPlayers(true).contains(p))
|
||||
return;
|
||||
|
||||
p.getInventory().clear();
|
||||
p.getInventory().setArmorContents(null);
|
||||
|
||||
p.getInventory().setItem(0, type.getLoadout().getSword());
|
||||
p.getInventory().setItem(1, type.getLoadout().getRod());
|
||||
p.getInventory().setItem(2, type.getLoadout().getBow());
|
||||
p.getInventory().setItem(8, type.getLoadout().getArrows());
|
||||
|
||||
p.getInventory().setHelmet(type.getLoadout().getHelmet());
|
||||
p.getInventory().setChestplate(type.getLoadout().getChestplate());
|
||||
p.getInventory().setLeggings(type.getLoadout().getLeggings());
|
||||
p.getInventory().setBoots(type.getLoadout().getBoots());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void arenaNeedsMoving(UpdateEvent e)
|
||||
{
|
||||
if (e.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Arena a : _gameArenaSet)
|
||||
{
|
||||
for (Player p : a.getPastPlayers())
|
||||
{
|
||||
if (!GetPlayers(true).contains(p))
|
||||
a.getPastPlayers().remove(p);
|
||||
}
|
||||
|
||||
if (a.getPastPlayers().size() == 1)
|
||||
{
|
||||
if (a.isOpenDoor())
|
||||
continue;
|
||||
|
||||
a.openDoor();
|
||||
a.getPastPlayers().get(0).sendMessage("§7§lDEBUG: §3Door has been opened in your arena.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void alert(UpdateEvent e)
|
||||
{
|
||||
if (e.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.trackers;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.game.games.gladiators.Gladiators;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 08/12/15
|
||||
*/
|
||||
public class BrawlerTracker extends StatTracker<Gladiators>
|
||||
{
|
||||
public BrawlerTracker(Gladiators game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void death(CombatDeathEvent e)
|
||||
{
|
||||
if (e.GetLog().GetKiller() == null)
|
||||
return;
|
||||
|
||||
if (Bukkit.getPlayerExact(e.GetLog().GetKiller().GetName()) != null)
|
||||
{
|
||||
Player p = Bukkit.getPlayerExact(e.GetLog().GetKiller().GetName());
|
||||
if (p.getItemInHand() == null)
|
||||
return;
|
||||
|
||||
if (p.getItemInHand().getType().equals(Material.AIR))
|
||||
addStat(p, "Brawler", 1, false, false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user