Better See Chunk
This commit is contained in:
@ -36,6 +36,7 @@ public class CmdFactions extends FactionsCommand
|
||||
public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader();
|
||||
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
||||
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
||||
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
|
||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
||||
public CmdFactionsAutoClaim cmdFactionsAutoClaim = new CmdFactionsAutoClaim();
|
||||
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
||||
@ -82,6 +83,7 @@ public class CmdFactions extends FactionsCommand
|
||||
this.addSubCommand(this.cmdFactionsLeader);
|
||||
this.addSubCommand(this.cmdFactionsMoney);
|
||||
this.addSubCommand(this.cmdFactionsSeeChunk);
|
||||
this.addSubCommand(this.cmdFactionsSeeChunkOld);
|
||||
this.addSubCommand(this.cmdFactionsClaim);
|
||||
this.addSubCommand(this.cmdFactionsAutoClaim);
|
||||
this.addSubCommand(this.cmdFactionsUnclaim);
|
||||
|
@ -1,16 +1,10 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsSeeChunk extends FactionsCommand
|
||||
{
|
||||
@ -22,9 +16,12 @@ public class CmdFactionsSeeChunk extends FactionsCommand
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("sc", "seechunk");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("active", "toggle");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SEE_CHUNK.node));
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SEECHUNK.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
@ -36,45 +33,24 @@ public class CmdFactionsSeeChunk extends FactionsCommand
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
World world = me.getWorld();
|
||||
PS chunk = PS.valueOf(me).getChunk(true);
|
||||
int chunkX = chunk.getChunkX();
|
||||
int chunkZ = chunk.getChunkZ();
|
||||
boolean old = msender.isSeeingChunk();
|
||||
boolean targetDefault = !old;
|
||||
Boolean target = this.arg(0, ARBoolean.get(), targetDefault);
|
||||
if (target == null) return;
|
||||
String targetDesc = Txt.parse(target ? "<g>ON": "<b>OFF");
|
||||
|
||||
// NoChange
|
||||
if (target.equals(old))
|
||||
{
|
||||
msg("<i>See Chunk is already %s<i>.", targetDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply
|
||||
int blockX;
|
||||
int blockZ;
|
||||
|
||||
blockX = chunkX*16;
|
||||
blockZ = chunkZ*16;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16 + 15;
|
||||
blockZ = chunkZ*16;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16;
|
||||
blockZ = chunkZ*16 + 15;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16 + 15;
|
||||
blockZ = chunkZ*16 + 15;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
msender.setSeeingChunk(target);
|
||||
|
||||
// Inform
|
||||
msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
|
||||
msg("<i>See Chunk is now %s<i>.", targetDesc);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void showPillar(Player player, World world, int blockX, int blockZ)
|
||||
{
|
||||
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
|
||||
{
|
||||
Location loc = new Location(world, blockX, blockY, blockZ);
|
||||
if (loc.getBlock().getType() != Material.AIR) continue;
|
||||
int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
|
||||
VisualizeUtil.addLocation(player, loc, typeId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
|
||||
|
||||
public class CmdFactionsSeeChunkOld extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSeeChunkOld()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("sco", "seechunkold");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SEECHUNKOLD.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
World world = me.getWorld();
|
||||
PS chunk = PS.valueOf(me).getChunk(true);
|
||||
int chunkX = chunk.getChunkX();
|
||||
int chunkZ = chunk.getChunkZ();
|
||||
|
||||
// Apply
|
||||
int blockX;
|
||||
int blockZ;
|
||||
|
||||
blockX = chunkX*16;
|
||||
blockZ = chunkZ*16;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16 + 15;
|
||||
blockZ = chunkZ*16;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16;
|
||||
blockZ = chunkZ*16 + 15;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
blockX = chunkX*16 + 15;
|
||||
blockZ = chunkZ*16 + 15;
|
||||
showPillar(me, world, blockX, blockZ);
|
||||
|
||||
// Inform
|
||||
msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void showPillar(Player player, World world, int blockX, int blockZ)
|
||||
{
|
||||
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
|
||||
{
|
||||
Location loc = new Location(world, blockX, blockY, blockZ);
|
||||
if (loc.getBlock().getType() != Material.AIR) continue;
|
||||
int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
|
||||
VisualizeUtil.addLocation(player, loc, typeId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user