Now using automated help. Fixed SeeChunk issues.

This commit is contained in:
Olof Larsson 2012-05-09 05:56:37 +02:00
parent 67e5aa8464
commit a0a163056d
8 changed files with 58 additions and 60 deletions

View File

@ -11,7 +11,6 @@ public class CmdFlag extends FCommand
{ {
super(); super();
this.aliases.add("flag"); this.aliases.add("flag");
this.aliases.add("flags");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("faction", "your");

View File

@ -61,7 +61,7 @@ public class CmdHelp extends FCommand
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( p.cmdBase.cmdHelp.getUseageTemplate(true) ); //pageLines.add( p.cmdBase.cmdHelp.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdList.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdList.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdShow.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdShow.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdPower.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdPower.getUseageTemplate(true) );

View File

@ -15,7 +15,6 @@ public class CmdPerm extends FCommand
{ {
super(); super();
this.aliases.add("perm"); this.aliases.add("perm");
this.aliases.add("perms");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("faction", "your");

View File

@ -56,12 +56,12 @@ public class CmdSeeChunk extends FCommand
public void showPillar(Player player, World world, int blockX, int blockZ) public void showPillar(Player player, World world, int blockX, int blockZ)
{ {
Location loc = new Location(world, blockX, 0, blockZ); for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
for (int blockY = 0; blockY <=127; blockY++)
{ {
loc.setY(blockY); Location loc = new Location(world, blockX, blockY, blockZ);
if (loc.getBlock().getTypeId() != 0) continue; if (loc.getBlock().getTypeId() != 0) continue;
VisualizeUtil.addLocation(player, loc.clone(), blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId()); int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
VisualizeUtil.addLocation(player, loc, typeId);
} }
} }

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import java.util.Collections; import java.util.Collections;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
public class FCmdRoot extends FCommand public class FCmdRoot extends FCommand
{ {
@ -17,7 +18,6 @@ public class FCmdRoot extends FCommand
public CmdDescription cmdDescription = new CmdDescription(); public CmdDescription cmdDescription = new CmdDescription();
public CmdDisband cmdDisband = new CmdDisband(); public CmdDisband cmdDisband = new CmdDisband();
public CmdFlag cmdFlag = new CmdFlag(); public CmdFlag cmdFlag = new CmdFlag();
public CmdHelp cmdHelp = new CmdHelp();
public CmdHome cmdHome = new CmdHome(); public CmdHome cmdHome = new CmdHome();
public CmdInvite cmdInvite = new CmdInvite(); public CmdInvite cmdInvite = new CmdInvite();
public CmdJoin cmdJoin = new CmdJoin(); public CmdJoin cmdJoin = new CmdJoin();
@ -67,47 +67,45 @@ public class FCmdRoot extends FCommand
this.setHelpShort("The faction base command"); this.setHelpShort("The faction base command");
this.helpLong.add(p.txt.parseTags("<i>This command contains all faction stuff.")); this.helpLong.add(p.txt.parseTags("<i>This command contains all faction stuff."));
//this.subCommands.add(p.cmdHelp); this.addSubCommand(P.p.cmdAutoHelp);
this.addSubCommand(this.cmdLeader);
this.addSubCommand(this.cmdAutoClaim);
this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdCape);
this.addSubCommand(this.cmdClaim);
this.addSubCommand(this.cmdConfig);
this.addSubCommand(this.cmdCreate);
this.addSubCommand(this.cmdDeinvite);
this.addSubCommand(this.cmdDescription);
this.addSubCommand(this.cmdDisband);
this.addSubCommand(this.cmdFlag);
this.addSubCommand(this.cmdHelp);
this.addSubCommand(this.cmdHome);
this.addSubCommand(this.cmdInvite);
this.addSubCommand(this.cmdJoin);
this.addSubCommand(this.cmdKick);
this.addSubCommand(this.cmdLeave);
this.addSubCommand(this.cmdList); this.addSubCommand(this.cmdList);
this.addSubCommand(this.cmdLock); this.addSubCommand(this.cmdShow);
this.addSubCommand(this.cmdMap);
this.addSubCommand(this.cmdOfficer);
this.addSubCommand(this.cmdMoney);
this.addSubCommand(this.cmdOpen);
this.addSubCommand(this.cmdPerm);
this.addSubCommand(this.cmdPower); this.addSubCommand(this.cmdPower);
this.addSubCommand(this.cmdPowerBoost); this.addSubCommand(this.cmdJoin);
this.addSubCommand(this.cmdLeave);
this.addSubCommand(this.cmdHome);
this.addSubCommand(this.cmdCreate);
this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdTag);
this.addSubCommand(this.cmdDescription);
this.addSubCommand(this.cmdCape);
this.addSubCommand(this.cmdPerm);
this.addSubCommand(this.cmdFlag);
this.addSubCommand(this.cmdInvite);
this.addSubCommand(this.cmdDeinvite);
this.addSubCommand(this.cmdOpen);
this.addSubCommand(this.cmdMoney);
this.addSubCommand(this.cmdClaim);
this.addSubCommand(this.cmdAutoClaim);
this.addSubCommand(this.cmdUnclaim);
this.addSubCommand(this.cmdUnclaimall);
this.addSubCommand(this.cmdKick);
this.addSubCommand(this.cmdOfficer);
this.addSubCommand(this.cmdLeader);
this.addSubCommand(this.cmdTitle);
this.addSubCommand(this.cmdMap);
this.addSubCommand(this.cmdSeeChunks);
this.addSubCommand(this.cmdDisband);
this.addSubCommand(this.cmdRelationAlly); this.addSubCommand(this.cmdRelationAlly);
this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationEnemy);
this.addSubCommand(this.cmdRelationNeutral); this.addSubCommand(this.cmdRelationNeutral);
this.addSubCommand(this.cmdRelationTruce); this.addSubCommand(this.cmdRelationTruce);
this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdPowerBoost);
this.addSubCommand(this.cmdLock);
this.addSubCommand(this.cmdReload); this.addSubCommand(this.cmdReload);
this.addSubCommand(this.cmdConfig);
this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSaveAll);
this.addSubCommand(this.cmdSeeChunks);
this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdShow);
this.addSubCommand(this.cmdTag);
this.addSubCommand(this.cmdTitle);
this.addSubCommand(this.cmdUnclaim);
this.addSubCommand(this.cmdUnclaimall);
this.addSubCommand(this.cmdVersion); this.addSubCommand(this.cmdVersion);
} }
@ -115,7 +113,7 @@ public class FCmdRoot extends FCommand
public void perform() public void perform()
{ {
this.commandChain.add(this); this.commandChain.add(this);
this.cmdHelp.execute(this.sender, this.args, this.commandChain); P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
} }
} }

View File

@ -48,7 +48,7 @@ public class Econ
if ( ! Conf.econEnabled) if ( ! Conf.econEnabled)
P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true"); P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
P.p.cmdBase.cmdHelp.updateHelp(); //P.p.cmdBase.cmdHelp.updateHelp();
oldMoneyDoTransfer(); oldMoneyDoTransfer();
} }

View File

@ -18,7 +18,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPreLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
@ -396,10 +395,4 @@ public class FactionsPlayerListener implements Listener
VisualizeUtil.clear(event.getPlayer()); VisualizeUtil.clear(event.getPlayer());
} }
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPreLogin(PlayerPreLoginEvent event)
{
VisualizeUtil.onPlayerPreLogin(event.getName());
}
} }

View File

@ -18,10 +18,19 @@ import org.bukkit.entity.Player;
public class VisualizeUtil public class VisualizeUtil
{ {
protected static Map<String, Set<Location>> playerLocations = new HashMap<String, Set<Location>>(); protected static Map<String, Set<Location>> playerLocations = new HashMap<String, Set<Location>>();
public static Set<Location> getPlayerLocations(Player player)
public static void onPlayerPreLogin(String name)
{ {
playerLocations.put(name, new HashSet<Location>()); return getPlayerLocations(player.getName());
}
public static Set<Location> getPlayerLocations(String playerName)
{
Set<Location> ret = playerLocations.get(playerName);
if (ret == null)
{
ret = new HashSet<Location>();
playerLocations.put(playerName, ret);
}
return ret;
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -30,13 +39,13 @@ public class VisualizeUtil
public static void addLocation(Player player, Location location, int typeId, byte data) public static void addLocation(Player player, Location location, int typeId, byte data)
{ {
playerLocations.get(player.getName()).add(location); getPlayerLocations(player).add(location);
player.sendBlockChange(location, typeId, data); player.sendBlockChange(location, typeId, data);
} }
public static void addLocation(Player player, Location location, int typeId) public static void addLocation(Player player, Location location, int typeId)
{ {
playerLocations.get(player.getName()).add(location); getPlayerLocations(player).add(location);
player.sendBlockChange(location, typeId, (byte) 0); player.sendBlockChange(location, typeId, (byte) 0);
} }
@ -46,7 +55,7 @@ public class VisualizeUtil
public static void addLocations(Player player, Map<Location, Integer> locationMaterialIds) public static void addLocations(Player player, Map<Location, Integer> locationMaterialIds)
{ {
Set<Location> ploc = playerLocations.get(player.getName()); Set<Location> ploc = getPlayerLocations(player);
for (Entry<Location, Integer> entry : locationMaterialIds.entrySet()) for (Entry<Location, Integer> entry : locationMaterialIds.entrySet())
{ {
ploc.add(entry.getKey()); ploc.add(entry.getKey());
@ -56,7 +65,7 @@ public class VisualizeUtil
public static void addLocations(Player player, Collection<Location> locations, int typeId) public static void addLocations(Player player, Collection<Location> locations, int typeId)
{ {
Set<Location> ploc = playerLocations.get(player.getName()); Set<Location> ploc = getPlayerLocations(player);
for (Location location : locations) for (Location location : locations)
{ {
ploc.add(location); ploc.add(location);
@ -66,7 +75,7 @@ public class VisualizeUtil
public static void addBlocks(Player player, Collection<Block> blocks, int typeId) public static void addBlocks(Player player, Collection<Block> blocks, int typeId)
{ {
Set<Location> ploc = playerLocations.get(player.getName()); Set<Location> ploc = getPlayerLocations(player);
for (Block block : blocks) for (Block block : blocks)
{ {
Location location = block.getLocation(); Location location = block.getLocation();
@ -81,14 +90,14 @@ public class VisualizeUtil
public static void clear(Player player) public static void clear(Player player)
{ {
Set<Location> locations = playerLocations.get(player.getName()); Set<Location> locations = getPlayerLocations(player);
if (locations == null) return; if (locations == null) return;
for (Location location : locations) for (Location location : locations)
{ {
Block block = location.getWorld().getBlockAt(location); Block block = location.getWorld().getBlockAt(location);
player.sendBlockChange(location, block.getTypeId(), block.getData()); player.sendBlockChange(location, block.getTypeId(), block.getData());
} }
playerLocations.remove(player); locations.clear();
} }
} }