Lots of bug fixes / additions since the testing 12/9/15.
This commit is contained in:
parent
87a834c01b
commit
af7c058f22
@ -0,0 +1,39 @@
|
||||
package nautilus.game.arcade.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 10/12/15
|
||||
*/
|
||||
public class FirstBloodEvent extends Event
|
||||
{
|
||||
|
||||
private Player player;
|
||||
|
||||
public FirstBloodEvent(Player player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
private static HandlerList _handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.gladiators;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -12,7 +11,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -293,6 +291,7 @@ public class Arena
|
||||
openDoor();
|
||||
|
||||
setState(ArenaState.RUNNING);
|
||||
setStateTime(System.currentTimeMillis());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8,25 +8,32 @@ import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -34,7 +41,13 @@ import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent;
|
||||
import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent;
|
||||
import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.BrawlerTracker;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.PrecisionTracker;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.SwiftKillTracker;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.UntouchableTracker;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
/**
|
||||
@ -75,6 +88,14 @@ public class Gladiators extends SoloGame
|
||||
HungerSet = 20;
|
||||
DontAllowOverfill = true;
|
||||
|
||||
registerStatTrackers(
|
||||
new BrawlerTracker(this),
|
||||
new UntouchableTracker(this),
|
||||
new FlawlessTracker(this),
|
||||
new PrecisionTracker(this),
|
||||
new SwiftKillTracker(this)
|
||||
);
|
||||
|
||||
_playerArenas = new HashMap<>();
|
||||
|
||||
_roundState = RoundState.WAITING;
|
||||
@ -177,7 +198,7 @@ public class Gladiators extends SoloGame
|
||||
{
|
||||
for(int i = 0; i < node.getChilds().length; i++)
|
||||
{
|
||||
System.out.println("Adding child of node: " + node.getColour() + "number of childs: " + node.getChilds().length);
|
||||
//System.out.println("Adding child of node: " + node.getColour() + "number of childs: " + node.getChilds().length);
|
||||
nextQueue.add(node.getChildAt(i));
|
||||
queue.add(node.getChildAt(i));
|
||||
}
|
||||
@ -188,7 +209,7 @@ public class Gladiators extends SoloGame
|
||||
Arena node = nextQueue.poll();
|
||||
node.setIsUsed(true);
|
||||
|
||||
System.out.println("Node: " + node.getColour());
|
||||
//System.out.println("Node: " + node.getColour());
|
||||
sum = sum + node.getCapacity() - 1;
|
||||
|
||||
/*
|
||||
@ -209,11 +230,11 @@ public class Gladiators extends SoloGame
|
||||
if (solved)
|
||||
{
|
||||
masterNode.getUsageMap(spawnsPerRoom);
|
||||
System.out.println("Solution: ");
|
||||
//System.out.println("Solution: ");
|
||||
|
||||
for (Map.Entry<Arena, Integer> entry : spawnsPerRoom.entrySet())
|
||||
{
|
||||
System.out.println("Color: " + entry.getKey().getColour() + ", Spawns: " + entry.getValue());
|
||||
//System.out.println("Color: " + entry.getKey().getColour() + ", Spawns: " + entry.getValue());
|
||||
_gameArenaSet.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
@ -354,7 +375,21 @@ public class Gladiators extends SoloGame
|
||||
a.setState(ArenaState.FIGHTING);
|
||||
a.setStateTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (a.getState() == ArenaState.WAITING)
|
||||
{
|
||||
// No fight for them, they have a bye.
|
||||
for (Player p : a.getPastPlayers())
|
||||
{
|
||||
p.sendMessage(ArcadeFormat.Line);
|
||||
p.sendMessage(" " + C.cWhite + C.Bold + "You have a bye!");
|
||||
p.sendMessage(" " + C.cGreen + "You automatically go through this round.");
|
||||
p.sendMessage(ArcadeFormat.Line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Manager.getPluginManager().callEvent(new RoundStartEvent());
|
||||
}
|
||||
else if (_roundState.equals(RoundState.FIGHTING))
|
||||
{
|
||||
@ -467,7 +502,7 @@ public class Gladiators extends SoloGame
|
||||
current.setState(ArenaState.WAITING);
|
||||
current.setDoBye(true);
|
||||
|
||||
Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3.");
|
||||
//Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3.");
|
||||
|
||||
giveLoadout(p, current.getColour()); //Kit
|
||||
p.setHealth(p.getMaxHealth()); //Heal
|
||||
@ -490,22 +525,24 @@ public class Gladiators extends SoloGame
|
||||
p.getInventory().setChestplate(type.getLoadout().getChestplate());
|
||||
p.getInventory().setLeggings(type.getLoadout().getLeggings());
|
||||
p.getInventory().setBoots(type.getLoadout().getBoots());
|
||||
|
||||
p.playSound(p.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void debug(PlayerCommandPreprocessEvent e){
|
||||
if (!e.getMessage().equalsIgnoreCase("/arenas"))
|
||||
return;
|
||||
e.setCancelled(true);
|
||||
Player p = e.getPlayer();
|
||||
|
||||
p.sendMessage("Round State = " + _roundState.toString());
|
||||
p.sendMessage("Out state = " + _furthestOutCurrent.toString());
|
||||
for (Arena a : _gameArenaSet)
|
||||
{
|
||||
p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString());
|
||||
}
|
||||
}
|
||||
// @EventHandler
|
||||
// public void debug(PlayerCommandPreprocessEvent e){
|
||||
// if (!e.getMessage().equalsIgnoreCase("/arenas"))
|
||||
// return;
|
||||
// e.setCancelled(true);
|
||||
// Player p = e.getPlayer();
|
||||
//
|
||||
// p.sendMessage("Round State = " + _roundState.toString());
|
||||
// p.sendMessage("Out state = " + _furthestOutCurrent.toString());
|
||||
// for (Arena a : _gameArenaSet)
|
||||
// {
|
||||
// p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void arenaUpdateTick(UpdateEvent e)
|
||||
@ -547,7 +584,7 @@ public class Gladiators extends SoloGame
|
||||
if (!_playerArenas.containsKey(p))
|
||||
return;
|
||||
|
||||
if (_playerArenas.get(p).getState() != ArenaState.FIGHTING)
|
||||
if ((_playerArenas.get(p).getState() != ArenaState.FIGHTING) || (_roundState != RoundState.FIGHTING))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -577,25 +614,37 @@ public class Gladiators extends SoloGame
|
||||
{
|
||||
_roundState = RoundState.STARTING_2;
|
||||
UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
|
||||
|
||||
for (Player p : UtilServer.getPlayers())
|
||||
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
|
||||
return;
|
||||
}
|
||||
else if (_roundState.equals(RoundState.STARTING_2))
|
||||
{
|
||||
_roundState = RoundState.STARTING_1;
|
||||
UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
|
||||
|
||||
for (Player p : UtilServer.getPlayers())
|
||||
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
|
||||
return;
|
||||
}
|
||||
else if (_roundState.equals(RoundState.STARTING_1))
|
||||
{
|
||||
_roundState = RoundState.STARTED;
|
||||
UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
|
||||
|
||||
for (Player p : UtilServer.getPlayers())
|
||||
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
|
||||
return;
|
||||
}
|
||||
else if (_roundState.equals(RoundState.STARTED))
|
||||
{
|
||||
_roundState = RoundState.FIGHTING;
|
||||
|
||||
UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
|
||||
UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 40, 0);
|
||||
|
||||
for (Player p : UtilServer.getPlayers())
|
||||
p.playSound(p.getLocation(), Sound.NOTE_PLING, 2f, 2f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -610,7 +659,7 @@ public class Gladiators extends SoloGame
|
||||
return "SEMI-FINALS";
|
||||
else if (size == 8)
|
||||
return "QUARTER-FINALS";
|
||||
else return "ROUND OF " + size;
|
||||
else return "ROUND OF " + size + " PLAYERS";
|
||||
}
|
||||
|
||||
public void setPlayerArena(Player p, Arena a)
|
||||
@ -663,7 +712,7 @@ public class Gladiators extends SoloGame
|
||||
if (a.getState() == ArenaState.FIGHTING)
|
||||
start = a.getStateTime();
|
||||
}
|
||||
double time = UtilMath.trim(1, ((60000L + start) - System.currentTimeMillis()));
|
||||
int time = Math.round((float)((60000L + start) - System.currentTimeMillis()));
|
||||
if (time < 0)
|
||||
Scoreboard.Write("Poison Active");
|
||||
else
|
||||
@ -721,4 +770,45 @@ public class Gladiators extends SoloGame
|
||||
p.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fireworkDeath(CombatDeathEvent e)
|
||||
{
|
||||
Location loc = e.GetEvent().getEntity().getLocation();
|
||||
Color color = Color.AQUA;
|
||||
switch (_furthestOutCurrent)
|
||||
{
|
||||
case RED:
|
||||
color = Color.RED;
|
||||
break;
|
||||
case ORANGE:
|
||||
color = Color.ORANGE;
|
||||
break;
|
||||
case YELLOW:
|
||||
color = Color.YELLOW;
|
||||
break;
|
||||
case GREEN:
|
||||
color = Color.GREEN;
|
||||
break;
|
||||
}
|
||||
UtilFirework.playFirework(loc, FireworkEffect.Type.BALL, color, false, false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void quitAlert(PlayerQuitEvent e)
|
||||
{
|
||||
if (_playerArenas.containsKey(e.getPlayer()))
|
||||
{
|
||||
for (Player p : _playerArenas.get(e.getPlayer()).getPastPlayers())
|
||||
{
|
||||
if (p.equals(e.getPlayer()))
|
||||
continue;
|
||||
|
||||
p.sendMessage(ArcadeFormat.Line);
|
||||
p.sendMessage(" " + C.cWhite + C.Bold + "Your opponent has QUIT!");
|
||||
p.sendMessage(" " + C.cGreen + "You automatically win the fight.");
|
||||
p.sendMessage(ArcadeFormat.Line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 10/12/15
|
||||
*/
|
||||
public class RoundStartEvent extends Event
|
||||
{
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.trackers;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import nautilus.game.arcade.events.FirstBloodEvent;
|
||||
import nautilus.game.arcade.game.games.gladiators.Gladiators;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 10/12/15
|
||||
*/
|
||||
public class SwiftKillTracker extends StatTracker<Gladiators>
|
||||
{
|
||||
public SwiftKillTracker(Gladiators game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blood(FirstBloodEvent e)
|
||||
{
|
||||
addStat(e.getPlayer(), "SwiftKill", 1, false, false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.trackers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.game.games.gladiators.Gladiators;
|
||||
import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 10/12/15
|
||||
*/
|
||||
public class UntouchableTracker extends StatTracker<Gladiators>
|
||||
{
|
||||
private List<String> _noWin;
|
||||
|
||||
public UntouchableTracker(Gladiators game)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_noWin = new ArrayList<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDmg(EntityDamageEvent e)
|
||||
{
|
||||
if (e.isCancelled())
|
||||
return;
|
||||
|
||||
if (e.getEntity() instanceof Player)
|
||||
{
|
||||
_noWin.add(((Player)e.getEntity()).getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnd(RoundStartEvent e)
|
||||
{
|
||||
for (Player p : getGame().GetPlayers(true))
|
||||
{
|
||||
if (_noWin.contains(p.getName()))
|
||||
return;
|
||||
|
||||
addStat(p, "Untouchable", 1, false, false);
|
||||
}
|
||||
|
||||
_noWin.clear();
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ import mineplex.serverdata.Utility;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.FirstBloodEvent;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
@ -77,6 +78,8 @@ public class GameGemManager implements Listener
|
||||
{
|
||||
game.AddGems(killer, 10, "First Blood", false, false);
|
||||
|
||||
Manager.getPluginManager().callEvent(new FirstBloodEvent(killer));
|
||||
|
||||
game.FirstKill = false;
|
||||
|
||||
game.Announce(F.main("Game", Manager.GetColor(killer) + killer.getName() + " drew first blood!"));
|
||||
|
Loading…
Reference in New Issue
Block a user