Removed Help plugin support as that plugin is not updated. Minor bugfixes and refactoring

This commit is contained in:
Olof Larsson 2011-04-08 16:03:04 +02:00
parent 443fac354a
commit 724ce03a40
11 changed files with 41 additions and 91 deletions

View File

@ -1,11 +1,9 @@
package org.mcteam.factions; package org.mcteam.factions;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
import org.mcteam.factions.gson.JsonParseException;
import org.mcteam.factions.util.DiscUtil; import org.mcteam.factions.util.DiscUtil;

View File

@ -56,8 +56,6 @@ import org.mcteam.factions.listeners.FactionsPlayerListener;
import com.nijiko.permissions.PermissionHandler; import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
import me.taylorkelly.help.Help;
/** /**
* The data is saved to disk every 30min and on plugin disable. * The data is saved to disk every 30min and on plugin disable.
*/ */
@ -79,7 +77,6 @@ public class Factions extends JavaPlugin {
private final FactionsBlockListener blockListener = new FactionsBlockListener(); private final FactionsBlockListener blockListener = new FactionsBlockListener();
public static PermissionHandler Permissions; public static PermissionHandler Permissions;
public static Help helpPlugin;
// Commands // Commands
public List<FBaseCommand> commands = new ArrayList<FBaseCommand>(); public List<FBaseCommand> commands = new ArrayList<FBaseCommand>();
@ -133,7 +130,6 @@ public class Factions extends JavaPlugin {
Faction.load(); Faction.load();
Board.load(); Board.load();
setupHelp();
setupPermissions(); setupPermissions();
// Register events // Register events
@ -176,21 +172,6 @@ public class Factions extends JavaPlugin {
// Integration with other plugins // Integration with other plugins
// -------------------------------------------- // // -------------------------------------------- //
private void setupHelp() {
if (helpPlugin != null) {
return;
}
Plugin test = this.getServer().getPluginManager().getPlugin("Help");
if (test != null) {
helpPlugin = ((Help) test);
Factions.log("Found and will use plugin "+helpPlugin.getDescription().getFullName());
helpPlugin.registerCommand(this.getBaseCommand()+" help *[page]", "Factions plugin help.", this, false);
helpPlugin.registerCommand("help factions", "instead use: /f help", helpPlugin, true);
}
}
private void setupPermissions() { private void setupPermissions() {
if (Permissions != null) { if (Permissions != null) {
return; return;
@ -277,7 +258,7 @@ public class Factions extends JavaPlugin {
} }
} }
sender.sendMessage(Conf.colorSystem+"Unknown faction command \""+commandName+"\". Try "+Conf.colorCommand+"/f help"); sender.sendMessage(Conf.colorSystem+"Unknown faction command \""+commandName+"\". Try "+Conf.colorCommand+"/"+this.getBaseCommand()+" help");
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -86,7 +86,7 @@ public class FBaseCommand {
} }
if (parameters.size() < requiredParameters.size()) { if (parameters.size() < requiredParameters.size()) {
sendMessage("Usage: "+this.getUseageTemplate(true)); sendMessage("Usage: "+this.getUseageTemplate(false));
return false; return false;
} }
@ -97,35 +97,14 @@ public class FBaseCommand {
return Factions.hasPermParticipate(sender); return Factions.hasPermParticipate(sender);
} }
/*public boolean testPermission(CommandSender sender) {
// There are two cases where we default to op:
// 1. Permissions is not installed
// 2. The sender is not a player
if ( Factions.Permissions == null || (! (sender instanceof Player))) {
if (this.opOnly && sender.isOp()) {
return true;
}
return false;
}
// No permissions are needed to use this command.
if (this.permissions.length() == 0) {
return true;
}
Player player = (Player)sender;
return Factions.Permissions.has(player, this.permissions);
}*/
// -------------------------------------------- // // -------------------------------------------- //
// Help and usage description // Help and usage description
// -------------------------------------------- // // -------------------------------------------- //
public String getUseageTemplate(boolean withColor, boolean withDescription) {
public String getUseageTemplate(boolean withDescription) {
String ret = ""; String ret = "";
if (withColor) { ret += Conf.colorCommand;
ret += Conf.colorCommand;
}
ret += Factions.instance.getBaseCommand()+ " " +TextUtil.implode(this.getAliases(), ",")+" "; ret += Factions.instance.getBaseCommand()+ " " +TextUtil.implode(this.getAliases(), ",")+" ";
@ -139,9 +118,7 @@ public class FBaseCommand {
parts.add("*["+optionalParameter+"]"); parts.add("*["+optionalParameter+"]");
} }
if (withColor) { ret += Conf.colorParameter;
ret += Conf.colorParameter;
}
ret += TextUtil.implode(parts, " "); ret += TextUtil.implode(parts, " ");
@ -151,10 +128,6 @@ public class FBaseCommand {
return ret; return ret;
} }
public String getUseageTemplate(boolean withColor) {
return getUseageTemplate(withColor, false);
}
public String getUseageTemplate() { public String getUseageTemplate() {
return getUseageTemplate(true); return getUseageTemplate(true);
} }

View File

@ -1,11 +1,9 @@
package org.mcteam.factions.commands; package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.mcteam.factions.Conf;
import org.mcteam.factions.Factions;
import com.bukkit.mcteam.factions.Conf;
import com.bukkit.mcteam.factions.Faction;
import com.bukkit.mcteam.factions.Factions;
import com.bukkit.mcteam.factions.struct.Role;
public class FCommandBypass extends FBaseCommand { public class FCommandBypass extends FBaseCommand {

View File

@ -53,7 +53,7 @@ public class FCommandCreate extends FBaseCommand {
follower.sendMessage(me.getNameAndRelevant(follower)+Conf.colorSystem+" created a new faction "+faction.getTag(follower)); follower.sendMessage(me.getNameAndRelevant(follower)+Conf.colorSystem+" created a new faction "+faction.getTag(follower));
} }
sendMessage("You should now: " + new FCommandDescription().getUseageTemplate(true, true)); sendMessage("You should now: " + new FCommandDescription().getUseageTemplate());
} }
} }

View File

@ -36,7 +36,7 @@ public class FCommandDeinvite extends FBaseCommand {
if (you.getFaction() == myFaction) { if (you.getFaction() == myFaction) {
sendMessage(you.getName()+" is already a member of "+myFaction.getTag()); sendMessage(you.getName()+" is already a member of "+myFaction.getTag());
sendMessage("You might want to: " + new FCommandKick().getUseageTemplate()); sendMessage("You might want to: " + new FCommandKick().getUseageTemplate(false));
return; return;
} }

View File

@ -52,45 +52,45 @@ public class FCommandHelp extends FBaseCommand {
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( new FCommandHelp().getUseageTemplate(true, true) ); pageLines.add( new FCommandHelp().getUseageTemplate() );
pageLines.add( new FCommandList().getUseageTemplate(true, true) ); pageLines.add( new FCommandList().getUseageTemplate() );
pageLines.add( new FCommandShow().getUseageTemplate(true, true) ); pageLines.add( new FCommandShow().getUseageTemplate() );
pageLines.add( new FCommandMap().getUseageTemplate(true, true) ); pageLines.add( new FCommandMap().getUseageTemplate() );
pageLines.add( new FCommandJoin().getUseageTemplate(true, true) ); pageLines.add( new FCommandJoin().getUseageTemplate() );
pageLines.add( new FCommandLeave().getUseageTemplate(true, true) ); pageLines.add( new FCommandLeave().getUseageTemplate() );
pageLines.add( new FCommandChat().getUseageTemplate(true, true) ); pageLines.add( new FCommandChat().getUseageTemplate() );
pageLines.add( new FCommandHome().getUseageTemplate(true, true) ); pageLines.add( new FCommandHome().getUseageTemplate() );
pageLines.add( "Learn how to create a faction on the next page." ); pageLines.add( "Learn how to create a faction on the next page." );
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( "Create a faction using these two commands:" ); pageLines.add( "Create a faction using these two commands:" );
pageLines.add( new FCommandCreate().getUseageTemplate(true, true) ); pageLines.add( new FCommandCreate().getUseageTemplate() );
pageLines.add( new FCommandDescription().getUseageTemplate(true, true) ); pageLines.add( new FCommandDescription().getUseageTemplate() );
pageLines.add( "You might wan't to close it and use invitations:" ); pageLines.add( "You might wan't to close it and use invitations:" );
pageLines.add( new FCommandOpen().getUseageTemplate(true, true) ); pageLines.add( new FCommandOpen().getUseageTemplate() );
pageLines.add( new FCommandInvite().getUseageTemplate(true, true) ); pageLines.add( new FCommandInvite().getUseageTemplate() );
pageLines.add( new FCommandDeinvite().getUseageTemplate(true, true) ); pageLines.add( new FCommandDeinvite().getUseageTemplate() );
pageLines.add( "And don't forget to set your home:" ); pageLines.add( "And don't forget to set your home:" );
pageLines.add( new FCommandSethome().getUseageTemplate(true, true) ); pageLines.add( new FCommandSethome().getUseageTemplate() );
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( "Faction can claim land that will be protected." ); pageLines.add( "Faction can claim land that will be protected." );
pageLines.add( new FCommandClaim().getUseageTemplate(true, true) ); pageLines.add( new FCommandClaim().getUseageTemplate() );
pageLines.add( new FCommandUnclaim().getUseageTemplate(true, true) ); pageLines.add( new FCommandUnclaim().getUseageTemplate() );
pageLines.add( new FCommandTag().getUseageTemplate(true, true) ); pageLines.add( new FCommandTag().getUseageTemplate() );
pageLines.add( new FCommandKick().getUseageTemplate(true, true) ); pageLines.add( new FCommandKick().getUseageTemplate() );
pageLines.add( new FCommandMod().getUseageTemplate(true, true) ); pageLines.add( new FCommandMod().getUseageTemplate() );
pageLines.add( new FCommandAdmin().getUseageTemplate(true, true) ); pageLines.add( new FCommandAdmin().getUseageTemplate() );
pageLines.add( new FCommandTitle().getUseageTemplate(true, true) ); pageLines.add( new FCommandTitle().getUseageTemplate() );
pageLines.add( "Player titles are just for fun. No rules connected to them." ); pageLines.add( "Player titles are just for fun. No rules connected to them." );
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( new FCommandRelationAlly().getUseageTemplate(true, true) ); pageLines.add( new FCommandRelationAlly().getUseageTemplate() );
pageLines.add( new FCommandRelationNeutral().getUseageTemplate(true, true) ); pageLines.add( new FCommandRelationNeutral().getUseageTemplate() );
pageLines.add( new FCommandRelationEnemy().getUseageTemplate(true, true) ); pageLines.add( new FCommandRelationEnemy().getUseageTemplate() );
pageLines.add(""); pageLines.add("");
pageLines.add("Set the relation you WISH to have with another faction."); pageLines.add("Set the relation you WISH to have with another faction.");
pageLines.add("Your default relation with other factions will be neutral."); pageLines.add("Your default relation with other factions will be neutral.");
@ -125,9 +125,9 @@ public class FCommandHelp extends FBaseCommand {
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add("Finally some commands for the server admins:"); pageLines.add("Finally some commands for the server admins:");
pageLines.add( new FCommandVersion().getUseageTemplate(true, true) ); pageLines.add( new FCommandVersion().getUseageTemplate() );
pageLines.add( new FCommandSafeclaim().getUseageTemplate(true, true) ); pageLines.add( new FCommandSafeclaim().getUseageTemplate() );
pageLines.add( new FCommandBypass().getUseageTemplate(true, true) ); pageLines.add( new FCommandBypass().getUseageTemplate() );
helpPages.add(pageLines); helpPages.add(pageLines);
} }

View File

@ -26,7 +26,7 @@ public class FCommandHome extends FBaseCommand {
if ( ! myFaction.hasHome()) { if ( ! myFaction.hasHome()) {
me.sendMessage("You faction does not have a home. " + (me.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); me.sendMessage("You faction does not have a home. " + (me.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:"));
me.sendMessage(new FCommandSethome().getUseageTemplate(true, true)); me.sendMessage(new FCommandSethome().getUseageTemplate());
return; return;
} }

View File

@ -36,7 +36,7 @@ public class FCommandInvite extends FBaseCommand {
if (you.getFaction() == myFaction) { if (you.getFaction() == myFaction) {
sendMessage(you.getName()+" is already a member of "+myFaction.getTag()); sendMessage(you.getName()+" is already a member of "+myFaction.getTag());
sendMessage("You might want to: " + new FCommandKick().getUseageTemplate()); sendMessage("You might want to: " + new FCommandKick().getUseageTemplate(false));
return; return;
} }

View File

@ -31,7 +31,7 @@ public class FCommandKick extends FBaseCommand {
if (me == you) { if (me == you) {
sendMessage("You cannot kick yourself."); sendMessage("You cannot kick yourself.");
sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate()); sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate(false));
return; return;
} }

View File

@ -32,7 +32,7 @@ public class FCommandSethome extends FBaseCommand {
myFaction.setHome(player.getLocation()); myFaction.setHome(player.getLocation());
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:"); myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
myFaction.sendMessage(new FCommandHome().getUseageTemplate(true, true)); myFaction.sendMessage(new FCommandHome().getUseageTemplate());
} }
} }