2011-11-24 16:27:14 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.entity.Player;
|
2013-04-09 12:56:29 +02:00
|
|
|
|
|
|
|
import com.massivecraft.factions.Perm;
|
2012-01-28 19:49:01 +01:00
|
|
|
import com.massivecraft.factions.util.VisualizeUtil;
|
2013-04-16 10:11:59 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
2013-04-16 09:48:57 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
2011-11-24 16:27:14 +01:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsSeeChunk extends FCommand
|
2011-11-24 16:27:14 +01:00
|
|
|
{
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsSeeChunk()
|
2011-11-24 16:27:14 +01:00
|
|
|
{
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("sc", "seechunk");
|
|
|
|
|
2013-04-25 13:25:15 +02:00
|
|
|
//this.addRequirements(ReqFactionsEnabled.get());
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.SEE_CHUNK.node));
|
2013-04-16 09:48:57 +02:00
|
|
|
this.addRequirements(ReqIsPlayer.get());
|
2011-11-24 16:27:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
Location meLoc = me.getLocation();
|
|
|
|
// Which chunk are we standing in ATM?
|
|
|
|
// This bit shifting is something like divide by 16 :P
|
|
|
|
int chunkX = meLoc.getBlockX() >> 4;
|
|
|
|
int chunkZ = meLoc.getBlockZ() >> 4;
|
|
|
|
|
|
|
|
// Get the pillars for that chunk
|
|
|
|
int blockX;
|
|
|
|
int blockZ;
|
|
|
|
|
|
|
|
blockX = chunkX*16;
|
|
|
|
blockZ = chunkZ*16;
|
|
|
|
showPillar(me, me.getWorld(), blockX, blockZ);
|
|
|
|
|
|
|
|
blockX = chunkX*16 + 15;
|
|
|
|
blockZ = chunkZ*16;
|
|
|
|
showPillar(me, me.getWorld(), blockX, blockZ);
|
|
|
|
|
|
|
|
blockX = chunkX*16;
|
|
|
|
blockZ = chunkZ*16 + 15;
|
|
|
|
showPillar(me, me.getWorld(), blockX, blockZ);
|
|
|
|
|
|
|
|
blockX = chunkX*16 + 15;
|
|
|
|
blockZ = chunkZ*16 + 15;
|
|
|
|
showPillar(me, me.getWorld(), blockX, blockZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void showPillar(Player player, World world, int blockX, int blockZ)
|
|
|
|
{
|
2012-05-09 05:56:37 +02:00
|
|
|
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
|
2011-11-24 16:27:14 +01:00
|
|
|
{
|
2012-05-09 05:56:37 +02:00
|
|
|
Location loc = new Location(world, blockX, blockY, blockZ);
|
2011-11-24 16:27:14 +01:00
|
|
|
if (loc.getBlock().getTypeId() != 0) continue;
|
2012-05-09 05:56:37 +02:00
|
|
|
int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
|
|
|
|
VisualizeUtil.addLocation(player, loc, typeId);
|
2011-11-24 16:27:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|