Lots of things

This commit is contained in:
Mysticate 2015-09-25 23:59:31 -04:00
parent 2de409c2f2
commit 30d2281785
3 changed files with 157 additions and 188 deletions

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Set;
@ -25,6 +26,7 @@ import mineplex.core.disguise.DisguiseFactory;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseMagmaCube;
import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.disguise.disguises.DisguiseSnowman;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -44,12 +46,9 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -58,12 +57,15 @@ import org.bukkit.event.player.PlayerInteractEvent;
public class Maze implements Listener
{
private MonsterMaze Host;
private ArrayList<Location> _spawns;
private ArrayList<Location> _map;
private ArrayList<Location> _goals;
private HashSet<Block> _waypoints;
private HashSet<Block> _disabledWaypoints;
private HashSet<Block> _oldDisabledWaypoints;
private ArrayList<Location> _safeZones;
private Location _center;
@ -71,15 +73,14 @@ public class Maze implements Listener
private ArrayList<Location> _playerContainmentUnitLocations = new ArrayList<>(); // probably could use a longer variable name...
private SafePad _safePad = null;
private SafePad _oldSafePad = null;
private LinkedList<SafePad> _oldSafePads = new LinkedList<SafePad>();
private ArrayList<Player> _playersOnPad = new ArrayList<Player>();
private double _phaseTimer = 60;
private double _phaseTimerStart = 60;
private int _padDecayTimer = -1;
private SafePad _nextSafePad;
private HashMap<Entity, MazeMobWaypoint> _ents = new HashMap<Entity, MazeMobWaypoint>();
@ -117,6 +118,10 @@ public class Maze implements Listener
}
_center = maze.getCenter();
spawnSafePad();
_safePad = _nextSafePad;
_nextSafePad = null;
Bukkit.getPluginManager().registerEvents(this, Host.Manager.getPlugin());
}
@ -176,19 +181,6 @@ public class Maze implements Listener
return;
decrementSafePadTime();
//Attempt pad spawn
// if (_safePad == null && UtilTime.elapsed(_lastBeacon, 3000 + (1000 * UtilMath.r(10))))
// {
// try
// {
// spawnSafePad();
// }
// catch (Exception ex)
// {
// System.out.println("AN EXCEPTION OCCURED WHILE TRYING TO SPAWN A SAFE PAD!");
// }
// }
}
@EventHandler
@ -243,9 +235,9 @@ public class Maze implements Listener
}
}
if(_oldSafePad != null)
for (SafePad oldSafePad : _oldSafePads)
{
if(_oldSafePad.isOn(e))
if(oldSafePad.isOn(e))
{
System.out.println("entity on old safepad removed");
it.remove();
@ -461,42 +453,44 @@ public class Maze implements Listener
}
}
Location loc = UtilAlg.Random(validSpawns);
Host.CreatureAllowOverride = true;
Entity ent = null;
if(Host.getMonsterType() == EntityType.ZOMBIE)
{
ent = loc.getWorld().spawn(loc, Zombie.class);
}
else if(Host.getMonsterType() == EntityType.SNOWMAN)
{
ent = loc.getWorld().spawn(loc, Snowman.class);
}
else if(Host.getMonsterType() == EntityType.CREEPER)
{
ent = loc.getWorld().spawn(loc, Creeper.class);
}
else
{
ent = loc.getWorld().spawn(loc, Zombie.class);
}
Host.CreatureAllowOverride = true;
Entity ent = loc.getWorld().spawn(loc, Snowman.class);
DisguiseBase disguise = DisguiseFactory.createDisguise(ent, Host.getMonsterType());
if (disguise instanceof DisguiseSlime)
{
((DisguiseSlime) disguise).SetSize(3);
}
if (disguise instanceof DisguiseMagmaCube)
{
((DisguiseMagmaCube) disguise).SetSize(3);
}
Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(ent);
UtilEnt.ghost(ent, true, false);
_ents.put(ent, new MazeMobWaypoint(ent.getLocation()));
if (disguise != null && !(disguise instanceof DisguiseSnowman))
{
Host.Manager.GetDisguise().disguise(disguise);
}
spawned++;
}
}
private void spawn(int numToSpawn)
{
System.out.println("spawning " + numToSpawn + " entities at spawnpoints");
Location loc = UtilAlg.Random(_spawns);
int spawned = 0;
while(spawned <= numToSpawn)
while (spawned <= numToSpawn)
{
Host.CreatureAllowOverride = true;
Entity ent = loc.getWorld().spawn(loc, Snowman.class);
@ -519,7 +513,7 @@ public class Maze implements Listener
UtilEnt.ghost(ent, true, false);
_ents.put(ent, new MazeMobWaypoint(ent.getLocation()));
if (disguise != null)
if (disguise != null && !(disguise instanceof DisguiseSnowman))
{
Host.Manager.GetDisguise().disguise(disguise);
}
@ -530,9 +524,9 @@ public class Maze implements Listener
private Location pickNextLocForSafePad() // short method name
{
if (_oldSafePad != null)
if (!_oldSafePads.isEmpty())
{
return UtilAlg.findFurthest(_oldSafePad.getLocation(), _goals);
return UtilAlg.findFurthest(_oldSafePads.getFirst().getLocation(), _goals);
}
else
{
@ -544,10 +538,9 @@ public class Maze implements Listener
{
if (_safePad != null)
{
_oldSafePad = _safePad;
_safePad.turnOffBeacon();
_oldSafePads.addLast(_safePad);
_safePad = null;
_oldSafePad.turnOffBeacon();
_padDecayTimer = 11;
_oldDisabledWaypoints = new HashSet<Block>(_disabledWaypoints);
}
@ -593,59 +586,14 @@ public class Maze implements Listener
public void decrementSafePadTime()
{
if(_padDecayTimer == -1) return;
_padDecayTimer--;
if(_oldSafePad != null)
Iterator<SafePad> iterator = _oldSafePads.iterator();
while (iterator.hasNext())
{
if(_padDecayTimer == 10)
SafePad pad = iterator.next();
if (pad.decay())
{
_oldSafePad.setBreakData((byte)5); // green
_oldSafePad.turnOffBeacon();
_oldSafePad.setCrackedProgress(1);
}
else if(_padDecayTimer == 9)
{
_oldSafePad.setCrackedProgress(2);
}
else if(_padDecayTimer == 8)
{
_oldSafePad.setBreakData((byte)4); // yellow
_oldSafePad.setCrackedProgress(3);
}
else if(_padDecayTimer == 7)
{
_oldSafePad.setCrackedProgress(4);
}
else if(_padDecayTimer == 6)
{
_oldSafePad.setBreakData((byte)1); // orange
_oldSafePad.setCrackedProgress(5);
}
else if(_padDecayTimer == 5)
{
_oldSafePad.setCrackedProgress(6);
}
else if(_padDecayTimer == 4)
{
_oldSafePad.setBreakData((byte)14); // red
_oldSafePad.setCrackedProgress(7);
}
else if(_padDecayTimer == 3)
{
_oldSafePad.setCrackedProgress(8);
}
else if(_padDecayTimer == 2)
{
_oldSafePad.setCrackedProgress(9);
}
else if(_padDecayTimer == 1)
{
_oldSafePad.setCrackedProgress(-1);
_oldSafePad.destroyBase();
_oldSafePad.destroySurface();
//TODO Deal with all this waypoint stuff
if(_oldDisabledWaypoints.size() > 0)
{
for(Block b : _oldDisabledWaypoints)
@ -655,17 +603,16 @@ public class Maze implements Listener
_oldDisabledWaypoints.clear();
}
_oldSafePad = null; // make sure mobs can go on it.
iterator.remove();
}
}
if (_padDecayTimer == 1)
{
_padDecayTimer = -1;
}
}
public void decrementPhaseTime()
{
if (_safePad == null)
return;
if(_phaseTimer == -1) return;
_phaseTimer -= .25;
@ -691,54 +638,23 @@ public class Maze implements Listener
if(_phaseTimer == 2)
{
UtilTextMiddle.display("", C.cGold + C.Bold + (int) _phaseTimer, 5, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
spawnSafePad();
UtilTextMiddle.display("", C.cGold + C.Bold + (int) _phaseTimer, 5, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
}
if(_phaseTimer == 1)
{
UtilTextMiddle.display("", C.cRed + C.Bold + (int) _phaseTimer, 5, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
}
if(_phaseTimer == 0)
{
for(Player p : Host.GetPlayers(true))
{
if(_safePad.isOn(p))
{
UtilTextMiddle.display("", C.cYellow + C.Bold + "The Safe Pad expired!", 5, 40, 5);
// maybe send them a happy message? =)
// UtilPlayer.message(p, F.main("Game", "Since you were on the Safe Pad, you didn't die!"));
}
else
{
Host.Manager.GetDamage().NewDamageEvent(p, null, null,
DamageCause.CUSTOM, 500, false, false, false,
"Game", "Map damage");
UtilTextMiddle.display("", C.cRed + C.Bold + "You didn't make it to the Safe Pad!", 5, 40, 5, p);
UtilPlayer.message(p, F.main("Game", "You didn't make it to the Safe Pad!"));
}
}
spawn(15);
stopSafePad();
_playersOnPad.clear();
//_phaseTimer = -1;
_phaseTimerStart = 90 - (_curSafe * 3);
_phaseTimer = _phaseTimerStart;
_safePad = _nextSafePad;
_nextSafePad = null;
for (Player p : Host.GetPlayers(true))
{
if(_safePad.isOn(p))
{
UtilTextMiddle.display("", C.cYellow + C.Bold + "Get to the Next Safe Pad!", 5, 40, 5);
// maybe send them a happy message? =)
// UtilPlayer.message(p, F.main("Game", "Since you were on the Safe Pad, you didn't die!"));
// UtilPlayer.message(p, F.main("Game", "Since you were on the Safe Pad, you didn't die!"));
}
else
{
@ -749,6 +665,19 @@ public class Maze implements Listener
UtilPlayer.message(p, F.main("Game", "You didn't make it to the Safe Pad!"));
}
}
spawn(15);
stopSafePad();
_playersOnPad.clear();
//_phaseTimer = -1;
_phaseTimerStart = 60 - (_curSafe * 3);
_phaseTimer = _phaseTimerStart;
spawnSafePad();
_safePad = _nextSafePad;
_nextSafePad = null;
}
}
@ -808,7 +737,7 @@ public class Maze implements Listener
if (allOn)
{
_phaseTimer = 4.0;
_phaseTimer = Math.min(4.0, _phaseTimer);
}
}

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade.game.games.monstermaze;
import java.util.regex.Pattern;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTextMiddle;
@ -31,15 +33,11 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scoreboard.Team;
@ -71,6 +69,8 @@ public class MonsterMaze extends SoloGame
});
this.DamagePvP = false;
this.DamagePvE = false;
this.DamageFall = false;
this.HungerSet = 20;
@ -93,23 +93,7 @@ public class MonsterMaze extends SoloGame
{
return _maze;
}
@EventHandler
public void health(EntityRegainHealthEvent event)
{
if(!(event.getEntity() instanceof Player)) return;
event.setCancelled(true);
}
// @EventHandler
// public void Update(UpdateEvent event)
// {
// if(event.getType() != UpdateType.TICK) return;
// if(_maze == null) return;
// _maze.update();
// }
@EventHandler
public void GameStateChange(GameStateChangeEvent event)
{
@ -118,13 +102,14 @@ public class MonsterMaze extends SoloGame
_maze.removePlayerContainmentUnit();
Announce(C.cYellow + C.Scramble + "@@" + C.cAqua + C.Bold + " Monster Maze is best played in 3rd Person! (Push F5) " + C.cYellow + C.Scramble + "@@");
UtilTextMiddle.display(C.cYellow + C.Bold + "Push F5", C.cAqua + C.Bold + "Monster Maze is best played in 3rd Person!");
// UtilTextMiddle.display(C.cYellow + C.Bold + "Push F5", C.cAqua + C.Bold + "Monster Maze is best played in 3rd Person!");
UtilTextMiddle.display("", C.cYellow + C.Bold + "Get to the Safe Pad!", 5, 40, 5);
for (Team team : GetScoreboard().GetScoreboard().getTeams())
team.setCanSeeFriendlyInvisibles(true);
}
else if(event.GetState() == GameState.Recruit)
{
{
_monsterType = loadEntityType();
_center = WorldData.GetDataLocs("ORANGE").get(0);
_preset = MMMazes.getRandomMapPreset(_center);
@ -147,14 +132,14 @@ public class MonsterMaze extends SoloGame
{
try
{
if (key.startsWith("E="))
if (key.startsWith("E"))
{
en = EntityType.valueOf(key.split("\\=")[1].toUpperCase());
en = EntityType.valueOf(key.split(Pattern.quote("="))[1].toUpperCase());
}
}
catch (Exception ex)
{
}
}
return en;
@ -170,25 +155,26 @@ public class MonsterMaze extends SoloGame
{
try
{
if (key.startsWith("B1="))
//B1=2:3
if (key.startsWith("B1"))
{
String[] typeData = key.split("\\=")[1].split("\\:");
String[] typeData = key.split(Pattern.quote("="))[1].split(Pattern.quote(","));
top = new MazeBlock(Material.getMaterial(Integer.valueOf(typeData[0])), Byte.valueOf(typeData[1]));
}
else if (key.startsWith("B2="))
else if (key.startsWith("B2"))
{
String[] typeData = key.split("\\=")[1].split("\\:");
String[] typeData = key.split(Pattern.quote("="))[1].split(Pattern.quote(","));
mid = new MazeBlock(Material.getMaterial(Integer.valueOf(typeData[0])), Byte.valueOf(typeData[1]));
}
else if (key.startsWith("B3="))
else if (key.startsWith("B3"))
{
String[] typeData = key.split("\\=")[1].split("\\:");
String[] typeData = key.split(Pattern.quote("="))[1].split(Pattern.quote(","));
bottom = new MazeBlock(Material.getMaterial(Integer.valueOf(typeData[0])), Byte.valueOf(typeData[1]));
}
}
catch (Exception ex)
{
// ex.printStackTrace();
}
}
@ -279,19 +265,10 @@ public class MonsterMaze extends SoloGame
e.setCancelled(true);
}
@EventHandler
public void Damage(EntityDamageEvent event)
{
if(event.getEntityType() == _monsterType) event.setCancelled(true); // TODO check to see if it's one of the entities
}
@EventHandler
public void onEntityCombust(EntityCombustEvent event)
{
if(event.getEntity() instanceof Zombie || event.getEntity() instanceof Skeleton)
{
event.setCancelled(true);
}
event.setCancelled(true);
}
public EntityType getMonsterType()

View File

@ -25,6 +25,8 @@ public class SafePad
private Location _loc;
private int _decayCount = 11;
private ArrayList<SafePadBlock> _blocks = new ArrayList<SafePadBlock>();
public SafePad(MonsterMaze host, Maze maze, Location loc)
@ -155,7 +157,7 @@ public class SafePad
}
}
public void setBreakData(byte newData)
private void setBreakData(byte newData)
{
for (SafePadBlock spb : _blocks)
{
@ -180,8 +182,69 @@ public class SafePad
}
}
}
public void setCrackedProgress(int progress)
public boolean decay()
{
if (_decayCount == -1)
return true;
_decayCount--;
if(_decayCount == 10)
{
setBreakData((byte)5); // green
setCrackedProgress(1);
}
else if(_decayCount == 9)
{
setCrackedProgress(2);
}
else if(_decayCount == 8)
{
setBreakData((byte)4); // yellow
setCrackedProgress(3);
}
else if(_decayCount == 7)
{
setCrackedProgress(4);
}
else if(_decayCount == 6)
{
setBreakData((byte)1); // orange
setCrackedProgress(5);
}
else if(_decayCount == 5)
{
setCrackedProgress(6);
}
else if(_decayCount == 4)
{
setBreakData((byte)14); // red
setCrackedProgress(7);
}
else if(_decayCount == 3)
{
setCrackedProgress(8);
}
else if(_decayCount == 2)
{
setCrackedProgress(9);
}
else if(_decayCount == 1)
{
_decayCount = -1;
setCrackedProgress(-1);
destroySurface();
destroyBase();
return true;
}
return false;
}
private void setCrackedProgress(int progress)
{
int i = 0;
Iterator<SafePadBlock> iter = _blocks.iterator();
@ -233,7 +296,7 @@ public class SafePad
{
for (final SafePadBlock bl : _blocks)
{
if (bl.getBlockMaterial() != Material.QUARTZ_BLOCK && bl.getBlockMaterial() != Material.QUARTZ_STAIRS)
if (bl.getBlockMaterial() == Material.STAINED_CLAY)
{
bl.restore();
}