Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2015-07-09 11:08:22 -05:00
commit f8b3431305
29 changed files with 977 additions and 126 deletions

View File

@ -19,6 +19,7 @@
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.Database" /> <element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
</root> </root>
</artifact> </artifact>
</component> </component>

View File

@ -37,7 +37,6 @@
</codeStyleSettings> </codeStyleSettings>
</value> </value>
</option> </option>
<option name="USE_PER_PROJECT_SETTINGS" value="true" /> <option name="PREFERRED_PROJECT_CODE_STYLE" value="Mineplex" />
</component> </component>
</project> </project>

View File

@ -1,6 +1,9 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Random; import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
@ -15,8 +18,9 @@ public class UtilMath
for (int i=1 ; i<degree ; i++) for (int i=1 ; i<degree ; i++)
format += "#"; format += "#";
DecimalFormat twoDForm = new DecimalFormat(format); DecimalFormatSymbols symb = new DecimalFormatSymbols(Locale.US);
DecimalFormat twoDForm = new DecimalFormat(format, symb);
return Double.valueOf(twoDForm.format(d)); return Double.valueOf(twoDForm.format(d));
} }

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade.command; package nautilus.game.arcade.command;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
@ -20,6 +22,10 @@ public class GameCommand extends MultiCommandBase<ArcadeManager>
@Override @Override
protected void Help(Player caller, String[] args) protected void Help(Player caller, String[] args)
{ {
UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:"));
UtilPlayer.message(caller, F.help("/game start", "Start the current game", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/game set <GameType> (Map)", "Set the current game or next game", Rank.ADMIN));
UtilPlayer.message(caller, F.main("Tip", "Use TAB for games/maps!"));
} }
} }

View File

@ -1,19 +1,18 @@
package nautilus.game.arcade.command; package nautilus.game.arcade.command;
import java.util.ArrayList; import mineplex.core.command.CommandBase;
import java.util.List; import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import nautilus.game.arcade.ArcadeManager; import java.util.ArrayList;
import nautilus.game.arcade.GameType; import java.util.List;
import nautilus.game.arcade.game.Game.GameState;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
public class SetCommand extends CommandBase<ArcadeManager> public class SetCommand extends CommandBase<ArcadeManager>
{ {
@ -28,9 +27,9 @@ public class SetCommand extends CommandBase<ArcadeManager>
if (Plugin.GetGame() == null) if (Plugin.GetGame() == null)
return; return;
if (args.length == 0) if (args == null || args.length == 0)
{ {
caller.sendMessage("/game set <GameType> (Map)"); caller.sendMessage(F.help("/game set <GameType> (Map)", "Set the current game or next game", Rank.ADMIN));
return; return;
} }
@ -43,7 +42,7 @@ public class SetCommand extends CommandBase<ArcadeManager>
} }
//Parse Game //Parse Game
ArrayList<GameType> matches = new ArrayList<GameType>(); ArrayList<GameType> matches = new ArrayList<>();
for (GameType type : GameType.values()) for (GameType type : GameType.values())
{ {
if (type.toString().toLowerCase().equals(game)) if (type.toString().toLowerCase().equals(game))

View File

@ -498,7 +498,11 @@ public abstract class Game implements Listener
UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin()); UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin());
for (Perk perk : kit.GetPerks()) for (Perk perk : kit.GetPerks())
UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin()); {
UtilServer.getServer().getPluginManager()
.registerEvents(perk, Manager.getPlugin());
perk.registeredEvents();
}
} }
} }

View File

@ -59,15 +59,16 @@ public class MineWare extends SoloGame
super(manager, GameType.MineWare, super(manager, GameType.MineWare,
new Kit[] new Kit[]
{ {
new KitNormal(manager), new KitNormal(manager),
}, },
new String[] new String[]
{ {
"Follow the orders given in chat!", "First half to follow it win the round.", "Other players lose one life.", "Follow the orders given in chat!",
"Last player with lives wins!" "First half to follow it win the round.",
}); "Other players lose one life.", "Last player with lives wins!"
});
DamageTeamSelf = true; DamageTeamSelf = true;
DamagePvP = false; DamagePvP = false;
@ -147,6 +148,8 @@ public class MineWare extends SoloGame
// _orders.add(ChallengeSkyFall.class); // _orders.add(ChallengeSkyFall.class);
_orders.add(ChallengeSmashOff.class); _orders.add(ChallengeSmashOff.class);
_orders.add(ChallengeTntLauncher.class); _orders.add(ChallengeTntLauncher.class);
//_orders.add(ChallengeSpleef.class); TODO
//_orders.add(ChallengeRunner.class); TODO
// _orders.add(ChallengeDiamondFall.class); // _orders.add(ChallengeDiamondFall.class);
} }
@ -161,17 +164,21 @@ public class MineWare extends SoloGame
_ordersCopy.addAll(_orders); _ordersCopy.addAll(_orders);
} }
Challenge challenge = _ordersCopy.remove(UtilMath.r(_ordersCopy.size())).getConstructor(MineWare.class) Challenge challenge = _ordersCopy
.newInstance(this); .remove(UtilMath.r(_ordersCopy.size()))
.getConstructor(MineWare.class).newInstance(this);
if (getChallengers().size() >= challenge.getMinPlayers()) if (getChallengers().size() >= challenge.getMinPlayers())
{ {
System.out.print("Using challenge " + challenge.getClass().getSimpleName()); System.out.print("Using challenge "
+ challenge.getClass().getSimpleName());
return challenge; return challenge;
} }
else else
{ {
System.out.print("Cannot use challenge " + challenge.getClass().getSimpleName() + ", not enough players"); System.out.print("Cannot use challenge "
+ challenge.getClass().getSimpleName()
+ ", not enough players");
} }
} }
@ -201,7 +208,8 @@ public class MineWare extends SoloGame
_order.generateRoom(); _order.generateRoom();
GetTeamList().get(0).SetSpawns(_order.getSpawns()); GetTeamList().get(0).SetSpawns(_order.getSpawns());
SpectatorSpawn = UtilWorld.averageLocation(_order.getSpawns()).add(0, 7, 0); SpectatorSpawn = UtilWorld.averageLocation(_order.getSpawns()).add(0,
7, 0);
} }
@EventHandler @EventHandler
@ -264,7 +272,10 @@ public class MineWare extends SoloGame
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f); player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
String message = C.cYellow + C.Bold + (IsAlive(player) ? challenge.getMessage(player) : challenge.GetOrder()); String message = C.cYellow
+ C.Bold
+ (IsAlive(player) ? challenge.getMessage(player)
: challenge.GetOrder());
UtilPlayer.message(player, message); UtilPlayer.message(player, message);
UtilTextMiddle.display(message, null); UtilTextMiddle.display(message, null);
@ -411,11 +422,10 @@ public class MineWare extends SoloGame
_orderTime = System.currentTimeMillis(); _orderTime = System.currentTimeMillis();
_orderWaiting = true; _orderWaiting = true;
/* XXX /*
GetObjectiveSide().setDisplayName( * XXX GetObjectiveSide().setDisplayName( ChatColor.WHITE +
ChatColor.WHITE + "§lMineWare " + C.cGreen + "§l" * "§lMineWare " + C.cGreen + "§l" + "Round " + _orderCount);
+ "Round " + _orderCount); */
*/
} }
else if (_orderWaiting) else if (_orderWaiting)
{ {
@ -427,7 +437,8 @@ public class MineWare extends SoloGame
_order.StartOrder(); _order.StartOrder();
// Register // Register
UtilServer.getServer().getPluginManager().registerEvents(_order, Manager.getPlugin()); UtilServer.getServer().getPluginManager()
.registerEvents(_order, Manager.getPlugin());
sayChallenge(_order); sayChallenge(_order);
} }
@ -454,8 +465,10 @@ public class MineWare extends SoloGame
_order.EndOrder(); _order.EndOrder();
_lastOrderBlocks = new ArrayList<Block>(_order.getModifiedBlocks()); _lastOrderBlocks = new ArrayList<Block>(
// Remove blocks from top to bottom, prevents blocks popping off. _order.getModifiedBlocks());
// Remove blocks from top to bottom, prevents blocks popping
// off.
Collections.sort(_lastOrderBlocks, new Comparator<Block>() Collections.sort(_lastOrderBlocks, new Comparator<Block>()
{ {
@ -475,8 +488,10 @@ public class MineWare extends SoloGame
// Set Level // Set Level
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
UtilTextTop.display(C.cYellow + C.Bold + (IsAlive(player) ? _order.getMessage(player) : _order.GetOrder()), UtilTextTop.display(C.cYellow
player); + C.Bold
+ (IsAlive(player) ? _order.getMessage(player)
: _order.GetOrder()), player);
player.setLevel(_order.GetRemainingPlaces()); player.setLevel(_order.GetRemainingPlaces());
player.setExp(_order.GetTimeLeftPercent()); player.setExp(_order.GetTimeLeftPercent());
} }
@ -509,13 +524,17 @@ public class MineWare extends SoloGame
if (lives > 0) if (lives > 0)
{ {
UtilPlayer.message(player, C.cRed + C.Bold + "You failed the task!"); UtilPlayer
UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!"); .message(player, C.cRed + C.Bold + "You failed the task!");
player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f); UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives
+ " lives left!");
player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f,
0.5f);
} }
else else
{ {
UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!"); UtilPlayer.message(player, C.cRed + C.Bold
+ "You are out of the game!");
player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f);
Scoreboard.ResetScore(player.getName()); Scoreboard.ResetScore(player.getName());

View File

@ -0,0 +1,125 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
public class ChallengeChickenFishing extends Challenge
{
private ArrayList<Entity> _chickens = new ArrayList<Entity>();
private ArrayList<Location> _spawns = new ArrayList<Location>();
private ArrayList<Location> _chickenSpawns = new ArrayList<Location>();
public ChallengeChickenFishing(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Chicken Fishing");
}
@Override
public ArrayList<Location> getSpawns()
{
return _spawns;
}
@EventHandler
public void onSecond(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
Iterator<Entity> itel = _chickens.iterator();
while (itel.hasNext())
{
Entity ent = itel.next();
// TODO Validate chicken is caught
if (!ent.isValid())
{
itel.remove();
}
}
for (Player player : getChallengers())
{
Block block = player.getLocation().getBlock();
if (block.isLiquid())
{
setLost(player);
}
}
}
@Override
public void cleanupRoom()
{
for (Entity chicken : _chickens)
{
chicken.remove();
}
}
@Override
public void setupPlayers()
{
for (Player player : getChallengers())
{
player.getInventory().addItem(new ItemStack(Material.FISHING_ROD));
}
}
@Override
public void generateRoom()
{
int size = (getChallengers().size() / 2) + 4;
for (Location location : UtilShapes.getCircle(getCenter(), true, size))
{
Block block = location.getBlock();
for (int y = 0; y <= 7; y++)
{
Block b = block.getRelative(0, y, 0);
if (y < 3 || (y < 5 && UtilMath.random.nextBoolean()))
{
b.setType(Material.STONE);
}
else if (y != 7)
{
b.setType(Material.DIRT);
}
else
{
b.setType(Material.GRASS);
}
}
_spawns.add(location.clone().add(0.5, 7.1, 0.5));
}
for (Location location : UtilShapes.getCircle(getCenter(), false,
size - 1))
{
_chickenSpawns.add(location.add(0.5, 0.5, 0.5));
}
}
}

View File

@ -55,7 +55,8 @@ public class ChallengeDragonEgg extends Challenge
@EventHandler @EventHandler
public void onBlockHit(PlayerInteractEvent event) public void onBlockHit(PlayerInteractEvent event)
{ {
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.LEFT_CLICK_BLOCK
&& event.getAction() != Action.RIGHT_CLICK_BLOCK)
{ {
return; return;
} }
@ -75,21 +76,25 @@ public class ChallengeDragonEgg extends Challenge
event.setCancelled(true); event.setCancelled(true);
block.setType(Material.AIR); block.setType(Material.AIR);
addBlock(block);
UtilParticle.PlayParticle(ParticleType.PORTAL, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0, 11, UtilParticle.PlayParticle(ParticleType.PORTAL,
ViewDist.MAX, UtilServer.getPlayers()); block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0,
11, ViewDist.MAX, UtilServer.getPlayers());
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
Block b = getCenter().clone().add(UtilMath.r(30) - 15, 1, UtilMath.r(30) - 15).getBlock(); Block b = getCenter().clone()
.add(UtilMath.r(30) - 15, 1, UtilMath.r(30) - 15)
.getBlock();
if (b.getType() == Material.AIR) if (b.getType() == Material.AIR)
{ {
Entity entity = getCenter().getWorld().spawnFallingBlock(b.getLocation().add(0.5, 2, 0.5), Material.DRAGON_EGG, Entity entity = getCenter().getWorld().spawnFallingBlock(
b.getLocation().add(0.5, 2, 0.5), Material.DRAGON_EGG,
(byte) 0); (byte) 0);
_dragonEggs.add(entity); _dragonEggs.add(entity);
for (int y = 0; y <= 2; y++) for (int y = 0; y <= 2; y++)
@ -107,9 +112,10 @@ public class ChallengeDragonEgg extends Challenge
int score = _smashedEggs.get(player.getName()) + 1; int score = _smashedEggs.get(player.getName()) + 1;
displayCount(player, block.getLocation().add(0.5, 1, 0.5), (score >= 10 ? C.cDGreen : score >= 7 ? C.cGreen displayCount(player, block.getLocation().add(0.5, 1, 0.5),
: score >= 4 ? C.cRed : C.cDRed) (score >= 10 ? C.cDGreen : score >= 7 ? C.cGreen
+ score); : score >= 4 ? C.cRed : C.cDRed)
+ score);
_smashedEggs.put(player.getName(), score); _smashedEggs.put(player.getName(), score);
@ -136,7 +142,10 @@ public class ChallengeDragonEgg extends Challenge
for (Player player : getChallengers()) for (Player player : getChallengers())
{ {
_smashedEggs.put(player.getName(), 0); _smashedEggs.put(player.getName(), 0);
player.getInventory().setItem(0, new ItemBuilder(Material.IRON_AXE).setTitle(C.cWhite + "Egg Smasher").build()); player.getInventory().setItem(
0,
new ItemBuilder(Material.IRON_AXE).setTitle(
C.cWhite + "Egg Smasher").build());
} }
} }
@ -157,7 +166,8 @@ public class ChallengeDragonEgg extends Challenge
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
Block b = getCenter().getBlock().getRelative(UtilMath.r(30) - 15, 1, UtilMath.r(30) - 15); Block b = getCenter().getBlock().getRelative(UtilMath.r(30) - 15,
1, UtilMath.r(30) - 15);
b.setType(Material.DRAGON_EGG); b.setType(Material.DRAGON_EGG);
addBlock(b); addBlock(b);
} }

View File

@ -0,0 +1,175 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
public class ChallengeRunner extends Challenge
{
private ArrayList<Entity> _fallingBlocks = new ArrayList<Entity>();
public ChallengeRunner(MineWare host)
{
super(host, ChallengeType.LastStanding,
"Blocks are disappearing beneath you! Run away!");
}
@Override
public ArrayList<Location> getSpawns()
{
return _spawns;
}
@Override
public void cleanupRoom()
{
for (Entity ent : _fallingBlocks)
{
ent.remove();
}
}
@Override
public void setupPlayers()
{
}
private ArrayList<Location> _spawns = new ArrayList<Location>();
@Override
public void generateRoom()
{
int amount = (int) Math.ceil(Math.sqrt(getChallengers().size()));
int a = UtilMath.r(16);
for (int pX = 0; pX < amount; pX++)
{
for (int pZ = 0; pZ < amount; pZ++)
{
if (++a > 15)
{
a = 0;
}
else if (a == 14)
{
a++;
}
_spawns.add(getCenter()
.add((pX * 4) + 1.5, 1.1, (pZ * 4) + 1.5));
for (int x = pX * 4; x < (pX * 4) + 2; x++)
{
for (int z = pZ * 4; z < (pZ * 4) + 2; z++)
{
Block b = getCenter().getBlock().getRelative(x, 0, z);
b.setType(Material.STAINED_CLAY);
b.setData((byte) a);
addBlock(b);
}
}
}
}
}
@EventHandler
public void BlockBreak(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
// Add Blocks
for (Player player : getChallengers())
{
// Side Standing
double xMod = player.getLocation().getX() % 1;
if (player.getLocation().getX() < 0)
xMod += 1;
double zMod = player.getLocation().getZ() % 1;
if (player.getLocation().getZ() < 0)
zMod += 1;
int xMin = 0;
int xMax = 0;
int zMin = 0;
int zMax = 0;
if (xMod < 0.3)
xMin = -1;
if (xMod > 0.7)
xMax = 1;
if (zMod < 0.3)
zMin = -1;
if (zMod > 0.7)
zMax = 1;
for (int x = xMin; x <= xMax; x++)
{
for (int z = zMin; z <= zMax; z++)
{
AddBlock(player.getLocation().add(x, -0.5, z).getBlock());
}
}
}
Iterator<Block> blockIterator = _blocks.keySet().iterator();
while (blockIterator.hasNext())
{
Block block = blockIterator.next();
if (!UtilTime.elapsed(_blocks.get(block), 600))
continue;
// Fall
int id = block.getTypeId();
byte data = block.getData();
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
FallingBlock ent = block.getWorld().spawnFallingBlock(
block.getLocation(), id, data);
_fallingBlocks.add(ent);
blockIterator.remove();
}
}
public void AddBlock(Block block)
{
if (block == null || block.getTypeId() == 0 || block.getTypeId() == 7
|| block.isLiquid())
return;
if (block.getRelative(BlockFace.UP).getTypeId() != 0)
return;
if (_blocks.containsKey(block))
return;
_blocks.put(block, System.currentTimeMillis());
block.setTypeIdAndData(159, (byte) 14, false);
}
private HashMap<Block, Long> _blocks = new HashMap<Block, Long>();
}

View File

@ -0,0 +1,103 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
public class ChallengeSpleef extends Challenge
{
public ChallengeSpleef(MineWare host)
{
super(host, ChallengeType.LastStanding,
"Destroy the blocks beneath other players!");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for (int x = -7; x <= 7; x++)
{
for (int z = -7; z <= 7; z++)
{
spawns.add(getCenter().clone().add(x + 0.5, 2, z + 0.5));
}
}
return spawns;
}
@Override
public void cleanupRoom()
{
}
@Override
public void setupPlayers()
{
}
@EventHandler
public void onBreak(PlayerInteractEvent event)
{
if (event.getAction() != Action.LEFT_CLICK_BLOCK)
{
return;
}
if (UtilPlayer.isSpectator(event.getPlayer()))
{
return;
}
Block block = event.getClickedBlock();
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND,
block.getTypeId());
block.setType(Material.AIR);
}
@Override
public void generateRoom()
{
for (int x = -15; x <= 15; x++)
{
for (int z = -15; z <= 15; z++)
{
Block block = getCenter().getBlock().getRelative(x, 0, z);
block.setType(Material.LAVA);
addBlock(block);
if (Math.abs(x) <= 10 && Math.abs(z) <= 10)
{
Block b = block.getRelative(0, 5, 0);
if (Math.abs(x) == 10 || Math.abs(z) == 10)
{
b.setType(Material.IRON_BLOCK);
}
else
{
b.setType(Material.WOOL);
block.setData((byte) UtilMath.r(16));
}
addBlock(b);
}
}
}
}
}

View File

@ -36,7 +36,7 @@ public class ChallengeVolleyPig extends Challenge
public ChallengeVolleyPig(MineWare host) public ChallengeVolleyPig(MineWare host)
{ {
super(host, ChallengeType.LastStanding, "Keep the pig on the other side and stack up the time!"); super(host, ChallengeType.FirstComplete, "Keep the pig on the other side and stack up the time!");
} }
@Override @Override

View File

@ -7,9 +7,6 @@
*/ */
$a1 = array(); $array = array();
$a2 = array($a1); array_push($array, $array);
print_r($array);
array_push($a1, $a2);
print_r($a1);

View File

@ -15,6 +15,7 @@ use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerLoginEvent; use pocketmine\event\player\PlayerLoginEvent;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\Player; use pocketmine\Player;
@ -40,9 +41,10 @@ class Main extends PluginBase implements Listener
$this->arena->getPlugin()->getServer()->getLevelByName("world")->setSpawnLocation(new Vector3(0, 200, 0)); $this->arena->getPlugin()->getServer()->getLevelByName("world")->setSpawnLocation(new Vector3(0, 200, 0));
} }
public function onLogin(PlayerLoginEvent $event) public function onLogin(PlayerLoginEvent $event)
{ {
UtilFile::deleteDir('players/' . $event->getPlayer()->getName() . '.dat'); //UtilFile::deleteDir('players/' . $event->getPlayer()->getName() . '.dat');
if ($this->arena->canJoin($event->getPlayer())) if ($this->arena->canJoin($event->getPlayer()))
return; return;

View File

@ -31,6 +31,12 @@ interface Arena
*/ */
public function hasPlayer($player); public function hasPlayer($player);
/**
* @param string $message
* @return void
*/
public function broadcast($message);
/** /**
* @return Plugin * @return Plugin
*/ */

View File

@ -72,6 +72,7 @@ class MultiGameArena implements Arena, Listener
public function endGame() public function endGame()
{ {
Server::getInstance()->broadcastMessage("Game Over!");
Server::getInstance()->getPluginManager()->callEvent(new ArenaEndEvent($this)); Server::getInstance()->getPluginManager()->callEvent(new ArenaEndEvent($this));
$this->startGame(); $this->startGame();
} }
@ -99,6 +100,14 @@ class MultiGameArena implements Arena, Listener
return in_array($player, $this->getPlayers()); return in_array($player, $this->getPlayers());
} }
public function broadcast($message)
{
foreach ($this->getPlayers() as $player)
{
$player->sendMessage($message);
}
}
public function getCurrentGame() public function getCurrentGame()
{ {
return $this->game; return $this->game;

View File

@ -69,7 +69,7 @@ class GameStateCountdown implements Listener, BenchTask {
public function run(BenchTaskData $data) public function run(BenchTaskData $data)
{ {
print "Count: $this->count"."\n"; print "§$this->startGameState---"."\n";
if ($this->count <= 0) if ($this->count <= 0)
{ {

View File

@ -12,22 +12,17 @@ use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent; use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent; use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent; use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent;
use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\gameengine\time\BenchSchedule; use mineplex\plugin\gameengine\time\BenchSchedule;
use mineplex\plugin\gameengine\time\BenchTask; use mineplex\plugin\gameengine\time\BenchTask;
use mineplex\plugin\gameengine\time\BenchTaskData; use mineplex\plugin\gameengine\time\BenchTaskData;
use pocketmine\entity\Effect;
use pocketmine\event\HandlerList; use pocketmine\event\HandlerList;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\network\protocol\AnimatePacket;
use pocketmine\network\protocol\ContainerSetDataPacket;
use pocketmine\network\protocol\DropItemPacket;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
class LobbyCountdown implements Listener, BenchTask { class LobbyCountdown implements Listener, BenchTask {
@ -42,13 +37,11 @@ class LobbyCountdown implements Listener, BenchTask {
private $message; private $message;
const WAITING_FOR_PLAYERS = "Waiting for players!";
const POPUP_ID = "popup"; const POPUP_ID = "popup";
const COUNTDOWN_ID = "count"; const COUNTDOWN_ID = "count";
public function __construct(Arena $arena, GameStateComponent $gameStateComponent, WorldComponent $worldComponent, $startGameState, $setGameState, $count, $minPlayers = 2) public function __construct(Arena $arena, GameStateComponent $gameStateComponent, $worldComponent = null, $startGameState, $setGameState, $count, $minPlayers = 2)
{ {
$this->arena = $arena; $this->arena = $arena;
$this->gameStateComponent = $gameStateComponent; $this->gameStateComponent = $gameStateComponent;
@ -61,9 +54,9 @@ class LobbyCountdown implements Listener, BenchTask {
$this->startGameState = $startGameState; $this->startGameState = $startGameState;
$this->setGameState = $setGameState; $this->setGameState = $setGameState;
$this->message = self::WAITING_FOR_PLAYERS;
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
$this->checkCountdown();
} }
@ -74,7 +67,7 @@ class LobbyCountdown implements Listener, BenchTask {
{ {
$playerCount = (count($this->arena->getPlayers()) + $addOne); $playerCount = (count($this->arena->getPlayers()) + $addOne);
if ($this->gameStateComponent->getGameState() == $this->startGameState && $this->worldComponent->isWorldReady() && $playerCount >= $this->minPlayers) if ($this->gameStateComponent->getGameState() == $this->startGameState && ($this->worldComponent == null || $this->worldComponent->isWorldReady()) && $playerCount >= $this->minPlayers)
{ {
if (!BenchSchedule::isRunningWithId($this, self::COUNTDOWN_ID)) if (!BenchSchedule::isRunningWithId($this, self::COUNTDOWN_ID))
{ {
@ -104,7 +97,8 @@ class LobbyCountdown implements Listener, BenchTask {
{ {
if ($event->getArena() !== $this->arena) if ($event->getArena() !== $this->arena)
return; return;
$this->checkCountdown(); if ($this->gameStateComponent->getGameState() == $this->startGameState)
$this->checkCountdown();
} }
public function onWorldCreation(WorldLoadSuccessEvent $event) public function onWorldCreation(WorldLoadSuccessEvent $event)
@ -192,6 +186,6 @@ class LobbyCountdown implements Listener, BenchTask {
private function popup(Player $player) private function popup(Player $player)
{ {
$player->sendTip($this->message); $player->sendPopup($this->message);
} }
} }

View File

@ -39,11 +39,11 @@ class ListenerFeature implements Feature, Listener {
} }
/** /**
* @return boolean * @return bool
*/ */
public function isEnabled() public function isEnabled()
{ {
$this->enabled; return $this->enabled;
} }
/** /**

View File

@ -0,0 +1,50 @@
<?php
/**
* Created by PhpStorm.
* User: Exerosis
* Date: 7/8/2015
* Time: 12:42 AM
*/
namespace mineplex\plugin\gameengine\game\components\feature\features;
use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
use mineplex\plugin\gameengine\game\components\spectate\SpectateComponent;
use pocketmine\Server;
class JoinSpectate extends ListenerFeature {
private $spectateComponent;
private $id;
function __construct(Arena $arena, SpectateComponent $spectateComponent)
{
parent::__construct($arena);
$this->spectateComponent = $spectateComponent;
$this->id = rand(0, 99999);
}
function onJoin(ArenaJoinEvent $event)
{
if ($this->getArena() !== $event->getArena())
return;
$this->spectateComponent->enableSpectate($event->getPlayer());
}
public function enable()
{
Server::getInstance()->broadcastMessage("JoinSpectate enable! : $this->id");
parent::enable();
print "JoinSpectate enable? " . ($this->isEnabled() ? 'true' : 'false') . "\n";
}
public function disable()
{
Server::getInstance()->broadcastMessage("JoinSpectate disable!");
parent::disable();
}
}

View File

@ -0,0 +1,46 @@
<?php
/**
* Created by PhpStorm.
* User: Exerosis
* Date: 7/8/2015
* Time: 12:46 AM
*/
namespace mineplex\plugin\gameengine\game\components\feature\features;
use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
use mineplex\plugin\gameengine\game\components\spectate\SpectateComponent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\Server;
class NoDamage extends ListenerFeature {
function __construct(Arena $arena)
{
parent::__construct($arena);
}
function onJoin(EntityDamageEvent $event)
{
if (!$this->getArena()->hasPlayer($event->getEntity()))
return;
$event->setCancelled();
}
public function enable()
{
Server::getInstance()->broadcastMessage("Death enable!");
parent::enable();
}
public function disable()
{
Server::getInstance()->broadcastMessage("Death disable!");
parent::disable();
}
}

View File

@ -40,7 +40,9 @@ class GameStateFeatureManager implements Listener {
foreach ($features as $key => $value) foreach ($features as $key => $value)
{ {
$this->features[$key] = UtilArray::getValuesRecursively($value); $this->features[$key] = UtilArray::getValuesRecursively($value);
print "$key: " . count($this->features[$key]) . "\n";
} }
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
@ -66,20 +68,55 @@ class GameStateFeatureManager implements Listener {
else else
$theseFeatures = []; $theseFeatures = [];
print "\nLast Count: ". count($lastFeatures);
print "\nThese Count: ". count($theseFeatures);
/** @var Feature[] $toEnable */ /** @var Feature[] $toEnable */
$toEnable = UtilArray::arrayDiff($theseFeatures, $lastFeatures); $toEnable = UtilArray::arrayDiff($theseFeatures, $lastFeatures);
print "\nEnable Count: ". count($toEnable);
/** @var Feature[] $toDisable */ /** @var Feature[] $toDisable */
$toDisable = UtilArray::arrayDiff($lastFeatures, $theseFeatures); $toDisable = UtilArray::arrayDiff($lastFeatures, $theseFeatures);
print "\nDisable Count: ". count($toDisable);
print "\n";
foreach ($toDisable as $feature)
{
if (in_array($feature, $theseFeatures))
print "An error has happened!!\n";
else
print "All good ^_^\n";
}
foreach ($toDisable as $feature) { foreach ($toDisable as $feature) {
if ($feature->isEnabled()) if ($feature->isEnabled())
{
print "Disable: " . get_class($feature) . spl_object_hash($feature) . "\n";
$feature->disable(); $feature->disable();
}
else
{
print get_class($feature) . "\n" . "Is already disabled!" . "\n";
}
} }
foreach ($toEnable as $feature) { foreach ($toEnable as $feature) {
if (!$feature->isEnabled()) if (!$feature->isEnabled())
{
print "Enable: " . get_class($feature) . spl_object_hash($feature) . "\n";
$feature->enable(); $feature->enable();
}
else
{
print get_class($feature) . "\n" . "Is already enabled!" . "\n";
}
} }
} }
public function onEnd(ArenaEndEvent $event) public function onEnd(ArenaEndEvent $event)
@ -87,7 +124,7 @@ class GameStateFeatureManager implements Listener {
if ($event->getArena() !== $this->arena) if ($event->getArena() !== $this->arena)
return; return;
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($this->features)); $iterator = UtilArray::getValuesRecursively($this->features);
foreach ($iterator as $feature) { foreach ($iterator as $feature) {
if ($feature->isEnabled()) if ($feature->isEnabled())

View File

@ -15,6 +15,7 @@ use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent
use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\Main; use mineplex\plugin\Main;
use mineplex\plugin\util\UtilArray; use mineplex\plugin\util\UtilArray;
use mineplex\plugin\util\UtilTeleport;
use pocketmine\event\HandlerList; use pocketmine\event\HandlerList;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\level\Position; use pocketmine\level\Position;
@ -86,8 +87,8 @@ class SimpleSpawnComponent implements SpawnComponent, Listener {
//$pos = $pos->getLevel()->getSpawnLocation(); //$pos = $pos->getLevel()->getSpawnLocation();
print_r($pos); print_r($pos);
UtilTeleport::teleport($player, $pos);
$player->teleport($pos); //$player->teleport($pos);
$player->sendMessage("After:"); $player->sendMessage("After:");
Main::sendLoc($player); Main::sendLoc($player);

View File

@ -0,0 +1,180 @@
<?php
/**
* Created by PhpStorm.
* User: Exerosis
* Date: 7/7/2015
* Time: 9:19 PM
*/
namespace mineplex\plugin\gameengine\game\components\victorytype;
use pocketmine\Player;
use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\game\components\spectate\SpectateComponent;
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
use pocketmine\event\Listener;
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
use mineplex\plugin\gameengine\game\components\spectate\events\EnableSpectateEvent;
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
use mineplex\plugin\gameengine\time\BenchTask;
use mineplex\plugin\gameengine\time\BenchSchedule;
use mineplex\plugin\gameengine\time\BenchTaskData;
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
use pocketmine\Server;
use mineplex\plugin\gameengine\game\components\feature\UtilFeature;
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
use pocketmine\event\HandlerList;
class LMSVictoryType implements Listener{
private $arena;
private $duringGame;
function __construct(Arena $arena, SpectateComponent $spectateComponent, GameStateComponent $gameStateComponent, $endPlayersAmount = 1)
{
$this->arena = $arena;
$this->duringGame = new DuringGame($arena, $spectateComponent, $gameStateComponent, $endPlayersAmount);
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
}
public function gameStateChange(GameStateChangeEvent $event)
{
if ($this->arena !== $event->getArena())
return;
if ($event->getToGameState() == GameState::GAME)
{
UtilFeature::enable($this->duringGame);
}
elseif ($event->getFromGameState() == GameState::GAME)
{
UtilFeature::disable($this->duringGame);
}
}
public function onEnd(ArenaEndEvent $event)
{
if ($this->arena !== $event->getArena())
return;
UtilFeature::disable($this->duringGame);
HandlerList::unregisterAll($this);
}
}
class DuringGame extends ListenerFeature implements BenchTask {
/** @var Player[] */
private $rank = [];
/** @var Arena */
private $arena;
/** @var SpectateComponent */
private $spectateComponent;
/** @var GameStateComponent */
private $gameStateComponent;
/** @var int */
private $endPlayersAmount;
function __construct(Arena $arena, SpectateComponent $spectateComponent, GameStateComponent $gameStateComponent, $endPlayersAmount = 1)
{
parent::__construct($arena);
$this->arena = $arena;
$this->spectateComponent = $spectateComponent;
$this->gameStateComponent = $gameStateComponent;
$this->endPlayersAmount = $endPlayersAmount;
}
#On LOWEST so I can check if the player is spectating, as the player is removed from the spectating list on LOW
/**
* @priority LOWEST
* @param ArenaQuitEvent $event
*/
public function onLeave(ArenaQuitEvent $event)
{
if ($this->arena !== $event->getArena())
return;
if (!$this->spectateComponent->isSpectating($event->getPlayer()))
array_push($this->rank, $event->getPlayer());
}
public function onSpectate(EnableSpectateEvent $event)
{
if ($this->arena !== $event->getArena())
return;
array_push($this->rank, $event->getPlayer());
$this->checkEndGame(true);
}
public function checkEndGame($subtract = false)
{
if ($this->gameStateComponent->getGameState() != GameState::GAME)
{
if ($this->isEnabled())
$this->disable();
return;
}
$count = count($this->spectateComponent->getNonSpectators()) - $subtract;
if ($count <= $this->endPlayersAmount)
{
$this->gameStateComponent->setGameState(GameState::POST_GAME);
}
}
private function sendWinners()
{
foreach ($this->spectateComponent->getNonSpectators() as $player)
{
array_push($this->rank, $player);
}
/** @var Player[] $rank */
$rank = array_reverse($this->rank);
$counter = 0;
$this->arena->broadcast("----------");
$this->arena->broadcast("");
foreach ($rank as $player)
{
$counter++;
$this->arena->broadcast("$counter. §e" . $player->getName());
if ($counter >= 3)
break;
}
$this->arena->broadcast("");
$this->arena->broadcast("----------");
}
public function run(BenchTaskData $task)
{
$this->checkEndGame();
}
public function enable()
{
BenchSchedule::runTaskLater($this, 0);
parent::enable();
}
public function disable()
{
$this->sendWinners();
BenchSchedule::cancelTask($this);
parent::disable();
}
}

View File

@ -18,6 +18,7 @@ use mineplex\plugin\util\UtilString;
use mineplex\plugin\util\UtilFile; use mineplex\plugin\util\UtilFile;
use pocketmine\event\HandlerList; use pocketmine\event\HandlerList;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\Server; use pocketmine\Server;

View File

@ -8,68 +8,62 @@
namespace mineplex\plugin\gameengine\game\games\sg; namespace mineplex\plugin\gameengine\game\games\sg;
use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown; use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown;
use mineplex\plugin\gameengine\game\components\countdown\LobbyCountdown;
use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate; use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate;
use mineplex\plugin\gameengine\game\components\feature\features\JoinSpectate;
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockBreak; use mineplex\plugin\gameengine\game\components\feature\features\NoBlockBreak;
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockPlace; use mineplex\plugin\gameengine\game\components\feature\features\NoBlockPlace;
use mineplex\plugin\gameengine\game\components\feature\features\NoDamage;
use mineplex\plugin\gameengine\game\components\feature\features\NoDropItem; use mineplex\plugin\gameengine\game\components\feature\features\NoDropItem;
use mineplex\plugin\gameengine\game\components\feature\features\NoPickUpItem; use mineplex\plugin\gameengine\game\components\feature\features\NoPickUpItem;
use mineplex\plugin\gameengine\game\components\feature\managers\GameStateFeatureManager; use mineplex\plugin\gameengine\game\components\feature\managers\GameStateFeatureManager;
use mineplex\plugin\gameengine\game\components\gamestate\GameState; use mineplex\plugin\gameengine\game\components\gamestate\GameState;
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent; use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
use mineplex\plugin\gameengine\game\components\lobby\LobbyComponent;
use mineplex\plugin\gameengine\game\components\spawn\SimpleSpawnComponent;
use mineplex\plugin\gameengine\game\components\spawn\SpawnAt;
use mineplex\plugin\gameengine\game\components\spectate\GameModeSpectateComponent; use mineplex\plugin\gameengine\game\components\spectate\GameModeSpectateComponent;
use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\gameengine\game\Game; use mineplex\plugin\gameengine\game\Game;
use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\game\components\feature\Feature;
use mineplex\plugin\gameengine\time\BenchSchedule;
use mineplex\plugin\gameengine\time\BenchTask;
use mineplex\plugin\gameengine\time\BenchTaskData;
use pocketmine\item\Item;
class SurvivalGames implements Game { class SurvivalGames implements Game {
/** @var Arena */
private $arena;
function start(Arena $arena) function start(Arena $arena)
{ {
$this->arena = $arena;
$gameStateComponent = new GameStateComponent($arena); $gameStateComponent = new GameStateComponent($arena);
//$spectateComponent = new GameModeSpectateComponent($arena); $spectateComponent = new GameModeSpectateComponent($arena);
//Init features //Init features
//$noPickUpItem = new NoPickUpItem($arena, [Item::GRASS], true); $noDamage = new NoDamage($arena);
$joinSpectate = new JoinSpectate($arena, $spectateComponent);
//$pack = array(new NoBlockBreak($arena, [Item::GRASS]), new NoBlockPlace($arena, [Item::WOOD], true),new NoDropItem($arena, [Item::APPLE], true)); $stopEveryThing = array(new NoBlockBreak($arena), new NoBlockPlace($arena),new NoDropItem($arena), new NoPickUpItem($arena));
/** @var Feature[][] $features */ /** @var Feature[][] $features */
//$features = array( $features = array(
// GameState::LOBBY => array($noPickUpItem, $pack)
//);
//new GameStateFeatureManager($arena, $features); //Just here cause I'm not using LobbyComponent atm
GameState::LOBBY => array( $stopEveryThing, $noDamage, ),
//new LobbyComponent($arena); GameState::PRE_GAME => array( $stopEveryThing, $noDamage, $joinSpectate),
$worldComponent = new WorldComponent($arena); GameState::GAME => array( $stopEveryThing, $joinSpectate , new DeathSpectate($arena, $spectateComponent)),
$spawnComponent = new SimpleSpawnComponent($arena, $worldComponent); GameState::POST_GAME => array($stopEveryThing, $noDamage, $joinSpectate),
new SpawnAt($arena, $spawnComponent, [GameState::PRE_GAME]); );
new LobbyCountdown($arena, $gameStateComponent, $worldComponent, GameState::LOBBY, GameState::PRE_GAME, 10, 1); new GameStateFeatureManager($arena, $features);
//new GameStateCountdown($arena, $gameStateComponent, 10, GameState::PRE_GAME, GameState::GAME); //new LobbyCountdown( $arena, $gameStateComponent, null, GameState::LOBBY, GameState::PRE_GAME, 10, 2);
//new GameStateCountdown($arena, $gameStateComponent, 20, GameState::GAME, GameState::POST_GAME); new GameStateCountdown($arena, $gameStateComponent, 5, GameState::LOBBY, GameState::PRE_GAME);
//new GameStateCountdown($arena, $gameStateComponent, 10, GameState::POST_GAME, GameState::RESTARTING); new GameStateCountdown($arena, $gameStateComponent, 5, GameState::PRE_GAME, GameState::GAME);
new GameStateCountdown($arena, $gameStateComponent, 5, GameState::GAME, GameState::POST_GAME);
//new LMSVictoryType( $arena, $spectateComponent, $gameStateComponent);
new GameStateCountdown($arena, $gameStateComponent, 5, GameState::POST_GAME, GameState::RESTARTING);
} }
} }

View File

@ -51,4 +51,12 @@ class UtilArray {
return $returnArray; return $returnArray;
} }
} }
/*
$obj1 = new \stdClass();
$a1=array("a"=>$obj1,"b"=>"green","c"=>"blue");
$a2=array("d"=>$obj1,"b"=>"black","e"=>"blue");
$result=UtilArray::arrayDiff($a1,$a2);
print_r($result);
print "hi";
*/

View File

@ -8,23 +8,20 @@ class UtilFile
{ {
if (! is_dir($dirPath)) if (! is_dir($dirPath))
{ {
throw new InvalidArgumentException("$dirPath must be a directory"); unlink($dirPath);
return;
} }
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') if (substr($dirPath, strlen($dirPath) - 1, 1) != '/')
{ {
$dirPath .= '/'; $dirPath .= '/';
} }
$files = glob($dirPath . '*', GLOB_MARK); $files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) foreach ($files as $file)
{ {
if (is_dir($file)) self::deleteDir($file);
{
self::deleteDir($file);
}
else
{
unlink($file);
}
} }
rmdir($dirPath); rmdir($dirPath);
} }

View File

@ -0,0 +1,84 @@
<?php
/**
* Created by PhpStorm.
* User: Exerosis
* Date: 7/7/2015
* Time: 2:31 PM
*/
namespace mineplex\plugin\util;
use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\network\protocol\MovePlayerPacket;
use pocketmine\network\protocol\RespawnPacket;
use pocketmine\network\protocol\SetSpawnPositionPacket;
use pocketmine\network\protocol\StartGamePacket;
use pocketmine\Player;
use pocketmine\network\protocol\UpdateBlockPacket;
class UtilTeleport {
public static function teleport(Player $player, Position $pos)
{
$player->noDamageTicks = 20;
//$player->teleport($pos);
$current = $player->getLevel();
if ($current->getName() != $pos->getLevel()) {
foreach ($pos->getLevel()->getTiles() as $tile)
{
$pk = new UpdateBlockPacket();
$pk->x = $tile->x;
$pk->y = $tile->y;
$pk->z = $tile->z;
$pk->block = $tile->getBlock();
$pk->meta = $tile->metadata;
Packet
$player->dataPacket($pk);
}
/*
foreach ($current->getTiles() as $tile) {
$pk = new UpdateBlockPacket();
$thereTile = $pos->getLevel()->getTile(new Vector3($tile->x, $tile->y, $tile->z));
$pk->x = $tile->x;
$pk->y = $tile->y;
$pk->z = $tile->z;
if ($thereTile !== null)
{
print "There tile is not null!";
$pk->block = $thereTile->getBlock();
$pk->meta = $thereTile->metadata;
}
else
{
print "null!";
$pk->block = 0;
$pk->meta = 0;
}
$player->dataPacket($pk);
}
*/
}
//$player->sendChunk()
$player->teleport($pos);
}
}