Lots of bug fixes / additions since the testing 12/9/15.

This commit is contained in:
William Burns 2015-12-10 19:06:07 +00:00
parent 87a834c01b
commit af7c058f22
7 changed files with 262 additions and 26 deletions

View File

@ -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();
}
}

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.game.games.gladiators; package nautilus.game.arcade.game.games.gladiators;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; 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.C;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -293,6 +291,7 @@ public class Arena
openDoor(); openDoor();
setState(ArenaState.RUNNING); setState(ArenaState.RUNNING);
setStateTime(System.currentTimeMillis());
return; return;
} }

View File

@ -8,25 +8,32 @@ import java.util.Map;
import java.util.Queue; import java.util.Queue;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; 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.common.util.UtilTextMiddle;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; 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.GameTeam;
import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; 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.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; import nautilus.game.arcade.kit.Kit;
/** /**
@ -75,6 +88,14 @@ public class Gladiators extends SoloGame
HungerSet = 20; HungerSet = 20;
DontAllowOverfill = true; DontAllowOverfill = true;
registerStatTrackers(
new BrawlerTracker(this),
new UntouchableTracker(this),
new FlawlessTracker(this),
new PrecisionTracker(this),
new SwiftKillTracker(this)
);
_playerArenas = new HashMap<>(); _playerArenas = new HashMap<>();
_roundState = RoundState.WAITING; _roundState = RoundState.WAITING;
@ -177,7 +198,7 @@ public class Gladiators extends SoloGame
{ {
for(int i = 0; i < node.getChilds().length; i++) 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)); nextQueue.add(node.getChildAt(i));
queue.add(node.getChildAt(i)); queue.add(node.getChildAt(i));
} }
@ -188,7 +209,7 @@ public class Gladiators extends SoloGame
Arena node = nextQueue.poll(); Arena node = nextQueue.poll();
node.setIsUsed(true); node.setIsUsed(true);
System.out.println("Node: " + node.getColour()); //System.out.println("Node: " + node.getColour());
sum = sum + node.getCapacity() - 1; sum = sum + node.getCapacity() - 1;
/* /*
@ -209,11 +230,11 @@ public class Gladiators extends SoloGame
if (solved) if (solved)
{ {
masterNode.getUsageMap(spawnsPerRoom); masterNode.getUsageMap(spawnsPerRoom);
System.out.println("Solution: "); //System.out.println("Solution: ");
for (Map.Entry<Arena, Integer> entry : spawnsPerRoom.entrySet()) 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()); _gameArenaSet.add(entry.getKey());
} }
} }
@ -354,8 +375,22 @@ public class Gladiators extends SoloGame
a.setState(ArenaState.FIGHTING); a.setState(ArenaState.FIGHTING);
a.setStateTime(System.currentTimeMillis()); 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)) else if (_roundState.equals(RoundState.FIGHTING))
{ {
for (Arena a : _gameArenaSet) for (Arena a : _gameArenaSet)
@ -467,7 +502,7 @@ public class Gladiators extends SoloGame
current.setState(ArenaState.WAITING); current.setState(ArenaState.WAITING);
current.setDoBye(true); 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 giveLoadout(p, current.getColour()); //Kit
p.setHealth(p.getMaxHealth()); //Heal p.setHealth(p.getMaxHealth()); //Heal
@ -490,22 +525,24 @@ public class Gladiators extends SoloGame
p.getInventory().setChestplate(type.getLoadout().getChestplate()); p.getInventory().setChestplate(type.getLoadout().getChestplate());
p.getInventory().setLeggings(type.getLoadout().getLeggings()); p.getInventory().setLeggings(type.getLoadout().getLeggings());
p.getInventory().setBoots(type.getLoadout().getBoots()); p.getInventory().setBoots(type.getLoadout().getBoots());
p.playSound(p.getLocation(), Sound.LEVEL_UP, 1f, 1f);
} }
@EventHandler // @EventHandler
public void debug(PlayerCommandPreprocessEvent e){ // public void debug(PlayerCommandPreprocessEvent e){
if (!e.getMessage().equalsIgnoreCase("/arenas")) // if (!e.getMessage().equalsIgnoreCase("/arenas"))
return; // return;
e.setCancelled(true); // e.setCancelled(true);
Player p = e.getPlayer(); // Player p = e.getPlayer();
//
p.sendMessage("Round State = " + _roundState.toString()); // p.sendMessage("Round State = " + _roundState.toString());
p.sendMessage("Out state = " + _furthestOutCurrent.toString()); // p.sendMessage("Out state = " + _furthestOutCurrent.toString());
for (Arena a : _gameArenaSet) // for (Arena a : _gameArenaSet)
{ // {
p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString()); // p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString());
} // }
} // }
@EventHandler @EventHandler
public void arenaUpdateTick(UpdateEvent e) public void arenaUpdateTick(UpdateEvent e)
@ -547,7 +584,7 @@ public class Gladiators extends SoloGame
if (!_playerArenas.containsKey(p)) if (!_playerArenas.containsKey(p))
return; return;
if (_playerArenas.get(p).getState() != ArenaState.FIGHTING) if ((_playerArenas.get(p).getState() != ArenaState.FIGHTING) || (_roundState != RoundState.FIGHTING))
e.setCancelled(true); e.setCancelled(true);
} }
@ -577,25 +614,37 @@ public class Gladiators extends SoloGame
{ {
_roundState = RoundState.STARTING_2; _roundState = RoundState.STARTING_2;
UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); 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; return;
} }
else if (_roundState.equals(RoundState.STARTING_2)) else if (_roundState.equals(RoundState.STARTING_2))
{ {
_roundState = RoundState.STARTING_1; _roundState = RoundState.STARTING_1;
UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); 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; return;
} }
else if (_roundState.equals(RoundState.STARTING_1)) else if (_roundState.equals(RoundState.STARTING_1))
{ {
_roundState = RoundState.STARTED; _roundState = RoundState.STARTED;
UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); 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; return;
} }
else if (_roundState.equals(RoundState.STARTED)) else if (_roundState.equals(RoundState.STARTED))
{ {
_roundState = RoundState.FIGHTING; _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; return;
} }
} }
@ -610,7 +659,7 @@ public class Gladiators extends SoloGame
return "SEMI-FINALS"; return "SEMI-FINALS";
else if (size == 8) else if (size == 8)
return "QUARTER-FINALS"; return "QUARTER-FINALS";
else return "ROUND OF " + size; else return "ROUND OF " + size + " PLAYERS";
} }
public void setPlayerArena(Player p, Arena a) public void setPlayerArena(Player p, Arena a)
@ -663,7 +712,7 @@ public class Gladiators extends SoloGame
if (a.getState() == ArenaState.FIGHTING) if (a.getState() == ArenaState.FIGHTING)
start = a.getStateTime(); start = a.getStateTime();
} }
double time = UtilMath.trim(1, ((60000L + start) - System.currentTimeMillis())); int time = Math.round((float)((60000L + start) - System.currentTimeMillis()));
if (time < 0) if (time < 0)
Scoreboard.Write("Poison Active"); Scoreboard.Write("Poison Active");
else 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.")); 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);
}
}
}
} }

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -16,6 +16,7 @@ import mineplex.serverdata.Utility;
import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.FirstBloodEvent;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
@ -77,6 +78,8 @@ public class GameGemManager implements Listener
{ {
game.AddGems(killer, 10, "First Blood", false, false); game.AddGems(killer, 10, "First Blood", false, false);
Manager.getPluginManager().callEvent(new FirstBloodEvent(killer));
game.FirstKill = false; game.FirstKill = false;
game.Announce(F.main("Game", Manager.GetColor(killer) + killer.getName() + " drew first blood!")); game.Announce(F.main("Game", Manager.GetColor(killer) + killer.getName() + " drew first blood!"));