Merge pull request #94 in MIN/mineplex from william-gladiators to master

* commit '0d4bd91b573ca251d15471b6454452bd4ebca195':
  lag detection thing
  Scoreboard change and breaking blocks.
  Couple of fixes
This commit is contained in:
Shaun Bennett 2015-12-11 18:57:52 -06:00
commit 402530d671
2 changed files with 74 additions and 5 deletions

View File

@ -257,9 +257,24 @@ public class Arena
}
public void closeDoor()
{
_host.Manager.getScheduler().scheduleSyncDelayedTask(_host.Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
for (Location loc : _doorBlocks)
loc.getBlock().setType(Material.OBSIDIAN);
// Lag exploit check
for (Player p : getPastPlayers())
{
Arena closest = _host.getArenaByMid(UtilAlg.findClosest(p.getLocation(), _host.getAllArenaMids()));
if (closest != _host.getPlayerArenas().get(p))
p.teleport(UtilAlg.findClosest(p.getLocation(), getSpawns()));
}
}
}, 5L);
}
public boolean isOpenDoor()

View File

@ -1,8 +1,10 @@
package nautilus.game.arcade.game.games.gladiators;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
@ -23,7 +25,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
@ -107,6 +108,10 @@ public class Gladiators extends SoloGame
DontAllowOverfill = true;
EnableTutorials = false;
BlockBreakAllow.add(Material.SUGAR_CANE_BLOCK.getId());
BlockBreakAllow.add(Material.GRASS.getId());
BlockBreakAllow.add(Material.LONG_GRASS.getId());
registerStatTrackers(
new BrawlerTracker(this),
//new UntouchableTracker(this),
@ -464,6 +469,11 @@ public class Gladiators extends SoloGame
return mids;
}
public HashMap<Player, Arena> getPlayerArenas()
{
return _playerArenas;
}
public ArrayList<Location> getAllArenaMids()
{
ArrayList<Location> mids = new ArrayList<>();
@ -671,9 +681,15 @@ public class Gladiators extends SoloGame
return;
}
if (!_playerArenas.get(p).isOpenDoor())
return;
//p.sendMessage("ARENA MOVE CHECK METHOD!");
Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), closest, _playerArenas.get(p)));
_playerArenas.put(p, closest);
// Push player a little
UtilAction.velocity(p, UtilAlg.getTrajectory2d(p.getLocation(), closest.getMid()), 1.7, false, 0.2, 0, 3, false);
}
}
@ -892,8 +908,8 @@ public class Gladiators extends SoloGame
if (e.getEntity() instanceof Player)
{
((Player)e.getEntity()).getInventory().addItem(new ItemStack(Material.ARROW, 1)); // Arrow fix.
((Player)e.getEntity()).updateInventory();
// ((Player)e.getEntity()).getInventory().addItem(new ItemStack(Material.ARROW, 1)); // Arrow fix.
// ((Player)e.getEntity()).updateInventory();
}
}
@ -1007,6 +1023,9 @@ public class Gladiators extends SoloGame
{
if (_playerArenas.containsKey(e.getPlayer()))
{
if (_playerArenas.get(e.getPlayer()).getState() != ArenaState.FIGHTING)
return;
for (Player p : _playerArenas.get(e.getPlayer()).getPastPlayers())
{
if (p.equals(e.getPlayer()))
@ -1019,4 +1038,39 @@ public class Gladiators extends SoloGame
}
}
}
@EventHandler
public void deathHealth(CombatDeathEvent e)
{
if (!(e.GetEvent().getEntity() instanceof Player))
return;
if (e.GetLog().GetKiller().IsPlayer())
{
Player killer = UtilPlayer.searchExact(e.GetLog().GetKiller().GetName());
((Player)e.GetEvent().getEntity()).sendMessage(F.main("Game", "Your killer had " + C.cRed + new DecimalFormat("#").format(killer.getHealth()) + "" + C.cGray + " left."));
}
}
@EventHandler
public void scoreboardEnd(GameStateChangeEvent e)
{
if (e.GetState() != GameState.End)
return;
Scoreboard.Reset();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGreen + C.Bold + "Status");
Scoreboard.Write(C.cWhite + "Ended");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cAqua + C.Bold + "Matches Left");
Scoreboard.Write(C.cWhite + "0");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Players");
if (getWinners() != null && !getWinners().isEmpty())
Scoreboard.Write(C.cWhite + getWinners().get(0).getName());
Scoreboard.Draw();
}
}