Start code refactoring.
This commit is contained in:
parent
e3a9f4f2f7
commit
215fe68575
@ -1 +1 @@
|
||||
[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core.Common","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core.Common"}},"ABSENT"]]
|
||||
[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"]]
|
@ -4,19 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.Hologram.HologramTarget;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -29,13 +16,27 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.Hologram.HologramTarget;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
public abstract class Challenge implements Listener
|
||||
{
|
||||
public enum ChallengeType
|
||||
{
|
||||
LastStanding, FirstComplete
|
||||
}
|
||||
|
||||
|
||||
public MineWare Host;
|
||||
|
||||
protected int Places;
|
||||
@ -56,41 +57,40 @@ public abstract class Challenge implements Listener
|
||||
|
||||
public Challenge(MineWare host, ChallengeType challengeType, String challengeName, String... challengeDes)
|
||||
{
|
||||
this.Host = host;
|
||||
this._challengeDesc = challengeDes;
|
||||
this._center = new Location(host.WorldData.World, 0, 0, 0);
|
||||
this._challengeType = challengeType;
|
||||
this._challengeName = challengeName;
|
||||
this._teamBased = false;
|
||||
this._crumble = false;
|
||||
|
||||
Host = host;
|
||||
_challengeDesc = challengeDes;
|
||||
_center = new Location(host.WorldData.World, 0, 0, 0);
|
||||
_challengeType = challengeType;
|
||||
_challengeName = challengeName;
|
||||
_teamBased = false;
|
||||
_crumble = false;
|
||||
|
||||
setBorder(-100, 100, 0, 256, -100, 100);
|
||||
}
|
||||
|
||||
public Challenge(MineWare host, ChallengeType challengeType, String challengeName, boolean teamBased, boolean crumble, String... challengeDes)
|
||||
|
||||
public Challenge(MineWare host, ChallengeType challengeType, String challengeName, boolean teamBased,
|
||||
boolean crumble, String... challengeDes)
|
||||
{
|
||||
this.Host = host;
|
||||
this._challengeDesc = challengeDes;
|
||||
this._center = new Location(host.WorldData.World, 0, 0, 0);
|
||||
this._challengeType = challengeType;
|
||||
this._challengeName = challengeName;
|
||||
this._teamBased = teamBased;
|
||||
this._crumble = crumble;
|
||||
|
||||
Host = host;
|
||||
_challengeDesc = challengeDes;
|
||||
_center = new Location(host.WorldData.World, 0, 0, 0);
|
||||
_challengeType = challengeType;
|
||||
_challengeName = challengeName;
|
||||
_teamBased = teamBased;
|
||||
_crumble = crumble;
|
||||
|
||||
setBorder(-100, 100, 0, 256, -100, 100);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if(!Host.IsLive())
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
}
|
||||
|
||||
removePlayerFromAllLists(event.getPlayer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getMaxTime()
|
||||
{
|
||||
return 60000;
|
||||
@ -101,26 +101,16 @@ public abstract class Challenge implements Listener
|
||||
return _modifiedBlocks;
|
||||
}
|
||||
|
||||
public String[] getGameMessages()
|
||||
{
|
||||
List<String> testing = new ArrayList<String>();
|
||||
for(String strings: _challengeDesc)
|
||||
{
|
||||
testing.add(strings);
|
||||
}
|
||||
testing.add("");
|
||||
|
||||
return testing.toArray(new String[testing.size()]);
|
||||
}
|
||||
|
||||
public void setBorder(int minX, int maxX, int minY, int maxY, int minZ, int maxZ)
|
||||
{
|
||||
Host.WorldData.MinX = minX;
|
||||
Host.WorldData.MaxX = maxX;
|
||||
Host.WorldData.MinY = minY;
|
||||
Host.WorldData.MaxY = maxY;
|
||||
Host.WorldData.MinZ = minZ;
|
||||
Host.WorldData.MaxZ = maxZ;
|
||||
WorldData data = Host.WorldData;
|
||||
|
||||
data.MinX = minX;
|
||||
data.MaxX = maxX;
|
||||
data.MinY = minY;
|
||||
data.MaxY = maxY;
|
||||
data.MinZ = minZ;
|
||||
data.MaxZ = maxZ;
|
||||
}
|
||||
|
||||
protected void addBlock(Block block)
|
||||
@ -128,8 +118,23 @@ public abstract class Challenge implements Listener
|
||||
if (!block.isEmpty())
|
||||
_modifiedBlocks.add(block);
|
||||
}
|
||||
|
||||
public String[] getGameMessages()
|
||||
{
|
||||
List<String> testing = new ArrayList<String>();
|
||||
|
||||
public void startOrder()
|
||||
for (String strings : _challengeDesc)
|
||||
{
|
||||
testing.add(strings);
|
||||
}
|
||||
|
||||
testing.add("");
|
||||
|
||||
return testing.toArray(new String[testing.size()]);
|
||||
}
|
||||
|
||||
|
||||
public void start()
|
||||
{
|
||||
CurrentPlaying = new HashSet<Player>(getChallengers());
|
||||
setupPlayers();
|
||||
@ -139,19 +144,15 @@ public abstract class Challenge implements Listener
|
||||
StartTime = System.currentTimeMillis();
|
||||
Duration = getMaxTime();
|
||||
Places = (int) Math.ceil(getChallengers().size() / 2D);
|
||||
|
||||
}
|
||||
|
||||
public void endOrder()
|
||||
public void end()
|
||||
{
|
||||
if(!_invisPlayers.isEmpty())
|
||||
{
|
||||
for(Player player: _invisPlayers)
|
||||
{
|
||||
Host.Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, "Challenge Ended");
|
||||
}
|
||||
}
|
||||
cleanupRoom();
|
||||
if (!_invisPlayers.isEmpty())
|
||||
for (Player player : _invisPlayers)
|
||||
Host.Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, "Challenge Ended");
|
||||
|
||||
cleanupRoom();
|
||||
}
|
||||
|
||||
protected void displayCount(Player player, Location loc, String string)
|
||||
@ -183,9 +184,6 @@ public abstract class Challenge implements Listener
|
||||
|
||||
public abstract void cleanupRoom();
|
||||
|
||||
/**
|
||||
* Register border
|
||||
*/
|
||||
public abstract void setupPlayers();
|
||||
|
||||
public abstract void generateRoom();
|
||||
@ -197,7 +195,7 @@ public abstract class Challenge implements Listener
|
||||
|
||||
public boolean finish()
|
||||
{
|
||||
boolean maxTimeReached = UtilTime.elapsed(StartTime, Duration);
|
||||
boolean maxTimeReached = UtilTime.elapsed(StartTime, Duration);
|
||||
ArrayList<Player> players = getChallengers();
|
||||
|
||||
if (players.size() <= Completed.size()) // 50% done
|
||||
@ -221,75 +219,79 @@ public abstract class Challenge implements Listener
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(maxTimeReached)
|
||||
if (maxTimeReached)
|
||||
{
|
||||
onChallengeTimeEnd();
|
||||
onChallengeTimeEnd();
|
||||
}
|
||||
return maxTimeReached;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
@EventHandler
|
||||
/**
|
||||
* Do not use this method!
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void mapCrumble(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.FASTEST)
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!Host.IsLive())
|
||||
if (!Host.IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!_crumble)
|
||||
if (!_crumble)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!Host.isCrumbling())
|
||||
if (!Host.isCrumbling())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Block qualifiedBlock = null;
|
||||
double furthestDistance = 0;
|
||||
|
||||
if(_modifiedBlocks.isEmpty())
|
||||
|
||||
if (_modifiedBlocks.isEmpty())
|
||||
{
|
||||
Host.setCrumbling(false);
|
||||
return;
|
||||
}
|
||||
for(Block currentBlock: _modifiedBlocks)
|
||||
for (Block currentBlock : _modifiedBlocks)
|
||||
{
|
||||
double theBlocksdistance = UtilMath.offset2d(Host.GetSpectatorLocation(), currentBlock.getLocation().add(0.5, 0.5, 0.5));
|
||||
if(qualifiedBlock == null || furthestDistance < theBlocksdistance)
|
||||
double theBlocksdistance = UtilMath.offset2d(Host.GetSpectatorLocation(),
|
||||
currentBlock.getLocation().add(0.5, 0.5, 0.5));
|
||||
if (qualifiedBlock == null || furthestDistance < theBlocksdistance)
|
||||
{
|
||||
qualifiedBlock = currentBlock;
|
||||
furthestDistance = theBlocksdistance;
|
||||
}
|
||||
}
|
||||
|
||||
//if blocks are layered:
|
||||
while(qualifiedBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR)
|
||||
|
||||
// if blocks are layered:
|
||||
while (qualifiedBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR)
|
||||
{
|
||||
qualifiedBlock = qualifiedBlock.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
_modifiedBlocks.remove(qualifiedBlock);
|
||||
if(UtilMath.r(4) == 0)
|
||||
if (UtilMath.r(4) == 0)
|
||||
{
|
||||
qualifiedBlock.getWorld().spawnFallingBlock(qualifiedBlock.getLocation().add(0.5, 0.5, 0.5), qualifiedBlock.getType(), qualifiedBlock.getData());
|
||||
qualifiedBlock.getWorld().spawnFallingBlock(qualifiedBlock.getLocation().add(0.5, 0.5, 0.5),
|
||||
qualifiedBlock.getType(), qualifiedBlock.getData());
|
||||
}
|
||||
MapUtil.QuickChangeBlockAt(qualifiedBlock.getLocation(), Material.AIR);
|
||||
}
|
||||
|
||||
/**This method is only called <br>
|
||||
|
||||
/**
|
||||
* This method is only called <br>
|
||||
* if the challenge ends due to <br>
|
||||
* exceeding the max time for the challenge <br>
|
||||
*/
|
||||
public void onChallengeTimeEnd() // Override-able
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getTimeLeft()
|
||||
@ -301,28 +303,28 @@ public abstract class Challenge implements Listener
|
||||
{
|
||||
if (Completed.contains(player))
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if(invis)
|
||||
if (invis)
|
||||
{
|
||||
_invisPlayers.add(player);
|
||||
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
|
||||
_invisPlayers.add(player);
|
||||
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
|
||||
}
|
||||
Completed.add(player);
|
||||
UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!");
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
||||
}
|
||||
|
||||
|
||||
public void SetCompleted(Player player)
|
||||
{
|
||||
setCompleted(player, false);
|
||||
setCompleted(player, false);
|
||||
}
|
||||
|
||||
public HashSet<Player> getLost()
|
||||
{
|
||||
return Lost;
|
||||
}
|
||||
|
||||
|
||||
public HashSet<Player> getWinners()
|
||||
{
|
||||
return Completed;
|
||||
@ -330,27 +332,27 @@ public abstract class Challenge implements Listener
|
||||
|
||||
public void setLost(Player player, boolean invis)
|
||||
{
|
||||
if(isDone(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!Host.isCrumbling())
|
||||
{
|
||||
Lost.add(player);
|
||||
}
|
||||
if(invis)
|
||||
{
|
||||
_invisPlayers.add(player);
|
||||
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
|
||||
}
|
||||
|
||||
Host.loseLife(player, false);
|
||||
UtilInv.Clear(player);
|
||||
if (isDone(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Host.isCrumbling())
|
||||
{
|
||||
Lost.add(player);
|
||||
}
|
||||
if (invis)
|
||||
{
|
||||
_invisPlayers.add(player);
|
||||
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
|
||||
}
|
||||
|
||||
Host.looseLife(player, false);
|
||||
UtilInv.Clear(player);
|
||||
}
|
||||
|
||||
|
||||
public void setLost(Player player)
|
||||
{
|
||||
setLost(player, false);
|
||||
setLost(player, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,19 +362,19 @@ public abstract class Challenge implements Listener
|
||||
{
|
||||
return Host.getChallengers();
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Player> getCurrentyAlive(boolean ignoreAlreadyWon)
|
||||
{
|
||||
ArrayList<Player> currentlyAlive = new ArrayList<Player>();
|
||||
for(Player player: CurrentPlaying)
|
||||
for (Player player : CurrentPlaying)
|
||||
{
|
||||
if(isLost(player))
|
||||
if (isLost(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(ignoreAlreadyWon)
|
||||
if (ignoreAlreadyWon)
|
||||
{
|
||||
if(isCompleted(player))
|
||||
if (isCompleted(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -386,48 +388,48 @@ public abstract class Challenge implements Listener
|
||||
{
|
||||
return Completed.contains(player);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDone(Player player)
|
||||
{
|
||||
if(Completed.contains(player) || Lost.contains(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Completed.contains(player) || Lost.contains(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isLost(Player player)
|
||||
{
|
||||
if(Lost.contains(player))
|
||||
if (Lost.contains(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void removePlayerFromAllLists(Player player)
|
||||
{
|
||||
if(Lost.contains(player))
|
||||
if (Lost.contains(player))
|
||||
{
|
||||
Lost.remove(player);
|
||||
}
|
||||
if(Completed.contains(player))
|
||||
if (Completed.contains(player))
|
||||
{
|
||||
Completed.remove(player);
|
||||
}
|
||||
if(_invisPlayers.contains(player))
|
||||
if (_invisPlayers.contains(player))
|
||||
{
|
||||
_invisPlayers.remove(player);
|
||||
}
|
||||
if(CurrentPlaying.contains(player))
|
||||
if (CurrentPlaying.contains(player))
|
||||
{
|
||||
CurrentPlaying.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getChallengeName()
|
||||
{
|
||||
return _challengeName;
|
||||
@ -453,43 +455,46 @@ public abstract class Challenge implements Listener
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public void onCollide(LivingEntity target, Block block, ProjectileUser data)
|
||||
{
|
||||
// For OverRide
|
||||
// For OverRide
|
||||
}
|
||||
|
||||
public int getMinPlayers()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxPlayers()
|
||||
{
|
||||
return 250;
|
||||
}
|
||||
|
||||
|
||||
public int getArenaSize()
|
||||
{
|
||||
return getArenaSize(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method, if there's too many people <br>
|
||||
* the max number will be 40!
|
||||
*
|
||||
* @param minBlocks
|
||||
* min number it will return
|
||||
* min number it will return
|
||||
* @return
|
||||
*/
|
||||
public int getArenaSize(int minBlocks)
|
||||
{
|
||||
int size = (int) (minBlocks + Math.ceil(Host.GetPlayers(true).size()/2));
|
||||
return size > 40 ? 40 : size;
|
||||
int size = (int) (minBlocks + Math.ceil(Host.GetPlayers(true).size() / 2));
|
||||
return size > 40 ? 40 : size;
|
||||
}
|
||||
|
||||
public boolean getTeamBased()
|
||||
{
|
||||
return _teamBased;
|
||||
}
|
||||
|
||||
|
||||
public boolean getCrumble()
|
||||
{
|
||||
return _crumble;
|
||||
|
@ -102,9 +102,9 @@ public abstract class ChallengeSeperateRooms extends Challenge
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOrder()
|
||||
public void start()
|
||||
{
|
||||
super.startOrder();
|
||||
super.start();
|
||||
|
||||
setBorder((int) -Math.ceil(_borderX), (int) Math.ceil(_borderX), 0, 256, (int) -Math.ceil(_borderZ),
|
||||
(int) Math.ceil(_borderZ));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -38,8 +38,15 @@ public class ChallengeArrowRampage extends Challenge
|
||||
|
||||
public ChallengeArrowRampage(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.LastStanding, "Arrow Rampage", false, true, "You are equipped with explosive arrows.",
|
||||
"Force your enemy into the void!");
|
||||
super(
|
||||
host,
|
||||
ChallengeType.LastStanding,
|
||||
"Arrow Rampage",
|
||||
false,
|
||||
true,
|
||||
"You are equipped with explosive arrows.",
|
||||
"Force your enemy into the void!"
|
||||
);
|
||||
|
||||
_antiHackFix = new AntiHackFix(this);
|
||||
}
|
||||
|
@ -30,18 +30,24 @@ import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeBlockLobbers extends Challenge
|
||||
{
|
||||
private ArrayList<Material> _tBlocks = new ArrayList<Material>(Arrays.asList(Material.GRASS, Material.DIRT, Material.SPONGE, Material.WOOD));
|
||||
private ArrayList<Material> _tBlocks = new ArrayList<Material>(
|
||||
Arrays.asList(Material.GRASS, Material.DIRT, Material.SPONGE, Material.WOOD));
|
||||
|
||||
public ChallengeBlockLobbers(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.LastStanding, "Block Lobbers", "Throw blocks to other players.", "Try to knock them off the platform!");
|
||||
super(
|
||||
host, ChallengeType.LastStanding,
|
||||
"Block Lobbers",
|
||||
"Throw blocks to other players.",
|
||||
"Try to knock them off the platform!"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
for(Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), true, 8))
|
||||
for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), true, 8))
|
||||
{
|
||||
spawns.add(getCenter().clone().add(locs.getX() + 0.5, 1.1, locs.getZ() + 0.5));
|
||||
}
|
||||
@ -51,9 +57,9 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
for(Entity fallingBlocks : Host.WorldData.World.getEntities())
|
||||
for (Entity fallingBlocks : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if(fallingBlocks instanceof FallingBlock || fallingBlocks instanceof Item)
|
||||
if (fallingBlocks instanceof FallingBlock || fallingBlocks instanceof Item)
|
||||
{
|
||||
fallingBlocks.remove();
|
||||
}
|
||||
@ -69,7 +75,7 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
for(Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), false, 11))
|
||||
for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), false, 11))
|
||||
{
|
||||
locs.getBlock().setType(Material.WOOL);
|
||||
locs.getBlock().setData((byte) UtilMath.r(16));
|
||||
@ -80,35 +86,36 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@EventHandler
|
||||
public void assignBlocks(UpdateEvent event)
|
||||
{
|
||||
if(!Host.IsLive())
|
||||
if (!Host.IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(event.getType() != UpdateType.FAST)
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach: for(Player players : Host.GetPlayers(true))
|
||||
foreach: for (Player players : Host.GetPlayers(true))
|
||||
{
|
||||
Material pickedMat = _tBlocks.get(UtilMath.r(_tBlocks.size()));
|
||||
|
||||
if(isDone(players))
|
||||
|
||||
if (isDone(players))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(players.getInventory().contains(pickedMat))
|
||||
if (players.getInventory().contains(pickedMat))
|
||||
{
|
||||
for(int i = 0; i < 10; i++)
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if(players.getInventory().getItem(i) != null)
|
||||
if (players.getInventory().getItem(i) != null)
|
||||
{
|
||||
if(players.getInventory().getItem(i).getType() == pickedMat)
|
||||
if (players.getInventory().getItem(i).getType() == pickedMat)
|
||||
{
|
||||
if(players.getInventory().getItem(i).getAmount() >= 10)
|
||||
if (players.getInventory().getItem(i).getAmount() >= 10)
|
||||
{
|
||||
continue foreach; //woah. Didn't know this syntax :O
|
||||
continue foreach; // woah. Didn't know this
|
||||
// syntax :O
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,21 +134,24 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@EventHandler
|
||||
public void onPlayerThrow(PlayerInteractEvent event)
|
||||
{
|
||||
if(!Host.IsLive())
|
||||
if (!Host.IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(isDone(event.getPlayer()))
|
||||
if (isDone(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
getFirstAvailableItem(event.getPlayer());
|
||||
if(!_tBlocks.contains(event.getPlayer().getItemInHand().getType())) // Stupid compass... <3
|
||||
if (!_tBlocks.contains(event.getPlayer().getItemInHand().getType())) // Stupid
|
||||
// compass...
|
||||
// <3
|
||||
{
|
||||
return;
|
||||
}
|
||||
FallingBlock fBlock = event.getPlayer().getWorld()
|
||||
.spawnFallingBlock(event.getPlayer().getLocation().clone().add(0, .4, 0), event.getPlayer().getItemInHand().getType(), (byte) 0);
|
||||
.spawnFallingBlock(event.getPlayer().getLocation().clone().add(0, .4, 0),
|
||||
event.getPlayer().getItemInHand().getType(), (byte) 0);
|
||||
|
||||
UtilInv.remove(event.getPlayer(), event.getPlayer().getItemInHand().getType(), (byte) 0, 1);
|
||||
UtilAction.velocity(fBlock, event.getPlayer().getLocation().getDirection(), 1.5, false, 0.0, 0.3, 10.0, true);
|
||||
@ -151,17 +161,17 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@EventHandler
|
||||
public void onFallingSandLand(EntityChangeBlockEvent event)
|
||||
{
|
||||
if(!Host.IsLive())
|
||||
if (!Host.IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Entity theEntity = event.getEntity();
|
||||
|
||||
if(theEntity instanceof FallingBlock)
|
||||
if (theEntity instanceof FallingBlock)
|
||||
{
|
||||
FallingBlock fb = (FallingBlock) theEntity;
|
||||
|
||||
if(fb.isOnGround())
|
||||
if (fb.isOnGround())
|
||||
{
|
||||
fb.getWorld().playEffect(fb.getLocation(), Effect.STEP_SOUND, fb.getBlockId());
|
||||
event.setCancelled(true);
|
||||
@ -172,42 +182,43 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@Override
|
||||
public void onCollide(LivingEntity target, Block block, ProjectileUser data)
|
||||
{
|
||||
if(!(data.GetThrown() instanceof FallingBlock))
|
||||
if (!(data.GetThrown() instanceof FallingBlock))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!(data.GetThrower() instanceof Player))
|
||||
if (!(data.GetThrower() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!(target instanceof Player))
|
||||
if (!(target instanceof Player))
|
||||
{
|
||||
//block.setType(Material.AIR);
|
||||
// block.setType(Material.AIR);
|
||||
return;
|
||||
}
|
||||
if(isCompleted((Player) target))
|
||||
if (isCompleted((Player) target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(target.equals(data.GetThrower()))
|
||||
if (target.equals(data.GetThrower()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown().getLocation(), target.getLocation()), 0.8, false, 0, 0.3, 0.5, true);
|
||||
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown().getLocation(), target.getLocation()), 0.8,
|
||||
false, 0, 0.3, 0.5, true);
|
||||
data.GetThrown().remove();
|
||||
}
|
||||
|
||||
public void getFirstAvailableItem(Player player)
|
||||
{
|
||||
if(player.getItemInHand().getType() == Material.AIR || player.getItemInHand().getType() == null)
|
||||
if (player.getItemInHand().getType() == Material.AIR || player.getItemInHand().getType() == null)
|
||||
{
|
||||
for(int i = 0; i <= 8; i++)
|
||||
for (int i = 0; i <= 8; i++)
|
||||
{
|
||||
if(player.getInventory().getItem(i) == null)
|
||||
if (player.getInventory().getItem(i) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(player.getInventory().getItem(i).getType() != Material.AIR)
|
||||
if (player.getInventory().getItem(i).getType() != Material.AIR)
|
||||
{
|
||||
player.getInventory().setHeldItemSlot(i);
|
||||
return;
|
||||
|
@ -7,19 +7,19 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
public class ChallengeEndEvent extends Event
|
||||
{
|
||||
private Challenge _endedChallenge;
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
private Challenge _endedChallenge;
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
public ChallengeEndEvent(Challenge challenge)
|
||||
{
|
||||
this._endedChallenge = challenge;
|
||||
}
|
||||
public ChallengeEndEvent(Challenge endedChallenge)
|
||||
{
|
||||
_endedChallenge = endedChallenge;
|
||||
}
|
||||
|
||||
public Challenge getEndedChallenge()
|
||||
{
|
||||
return _endedChallenge;
|
||||
}
|
||||
|
||||
public Challenge getEndedChallenge()
|
||||
{
|
||||
return _endedChallenge;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
@ -30,5 +30,4 @@ public class ChallengeEndEvent extends Event
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,17 +9,17 @@ public class ChallengeStartEvent extends Event
|
||||
{
|
||||
private Challenge _startedChallenge;
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
|
||||
public ChallengeStartEvent(Challenge startedChallenge)
|
||||
{
|
||||
this._startedChallenge = startedChallenge;
|
||||
_startedChallenge = startedChallenge;
|
||||
}
|
||||
|
||||
|
||||
public Challenge getStartedChallenge()
|
||||
{
|
||||
return _startedChallenge;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
|
@ -41,30 +41,24 @@ public class KitBawksFood extends Kit
|
||||
public void SpawnCustom(LivingEntity ent)
|
||||
{
|
||||
EntityEquipment equipment = ent.getEquipment();
|
||||
|
||||
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 3);
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
meta.setOwner(UtilSkull.getPlayerHeadName(EntityType.CHICKEN));
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
// ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
||||
// LeatherArmorMeta helmetMeta = (LeatherArmorMeta) helmet.getItemMeta();
|
||||
// helmetMeta.setColor(Color.WHITE);
|
||||
// helmetMeta.spigot().setUnbreakable(true);
|
||||
// helmet.setItemMeta(helmetMeta);
|
||||
|
||||
|
||||
ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
LeatherArmorMeta chestplateMeta = (LeatherArmorMeta) chestplate.getItemMeta();
|
||||
chestplateMeta.setColor(Color.WHITE);
|
||||
chestplateMeta.spigot().setUnbreakable(true);
|
||||
chestplate.setItemMeta(chestplateMeta);
|
||||
|
||||
|
||||
ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
LeatherArmorMeta leggingsMeta = (LeatherArmorMeta) leggings.getItemMeta();
|
||||
leggingsMeta.setColor(Color.WHITE);
|
||||
leggingsMeta.spigot().setUnbreakable(true);
|
||||
leggings.setItemMeta(leggingsMeta);
|
||||
|
||||
|
||||
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
|
||||
LeatherArmorMeta bootsMeta = (LeatherArmorMeta) boots.getItemMeta();
|
||||
bootsMeta.setColor(Color.WHITE);
|
||||
|
@ -16,7 +16,6 @@ public class MinewareTagMasterTracker extends StatTracker<Game>
|
||||
public MinewareTagMasterTracker(Game game)
|
||||
{
|
||||
super(game);
|
||||
System.out.println("3");
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
|
Loading…
Reference in New Issue
Block a user