From 724ce03a40c58b42ada535e3cb62a7585633d143 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 8 Apr 2011 16:03:04 +0200 Subject: [PATCH] Removed Help plugin support as that plugin is not updated. Minor bugfixes and refactoring --- src/org/mcteam/factions/Conf.java | 2 - src/org/mcteam/factions/Factions.java | 21 +------- .../factions/commands/FBaseCommand.java | 37 ++----------- .../factions/commands/FCommandBypass.java | 6 +-- .../factions/commands/FCommandCreate.java | 2 +- .../factions/commands/FCommandDeinvite.java | 2 +- .../factions/commands/FCommandHelp.java | 54 +++++++++---------- .../factions/commands/FCommandHome.java | 2 +- .../factions/commands/FCommandInvite.java | 2 +- .../factions/commands/FCommandKick.java | 2 +- .../factions/commands/FCommandSethome.java | 2 +- 11 files changed, 41 insertions(+), 91 deletions(-) diff --git a/src/org/mcteam/factions/Conf.java b/src/org/mcteam/factions/Conf.java index 559e317f..48c76661 100644 --- a/src/org/mcteam/factions/Conf.java +++ b/src/org/mcteam/factions/Conf.java @@ -1,11 +1,9 @@ package org.mcteam.factions; import java.io.File; -import java.io.IOException; import java.util.*; import org.bukkit.*; import org.bukkit.entity.CreatureType; -import org.mcteam.factions.gson.JsonParseException; import org.mcteam.factions.util.DiscUtil; diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index a857238d..9906a7b9 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -56,8 +56,6 @@ import org.mcteam.factions.listeners.FactionsPlayerListener; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; -import me.taylorkelly.help.Help; - /** * 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(); public static PermissionHandler Permissions; - public static Help helpPlugin; // Commands public List commands = new ArrayList(); @@ -133,7 +130,6 @@ public class Factions extends JavaPlugin { Faction.load(); Board.load(); - setupHelp(); setupPermissions(); // Register events @@ -176,21 +172,6 @@ public class Factions extends JavaPlugin { // 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() { if (Permissions != null) { 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"); } // -------------------------------------------- // diff --git a/src/org/mcteam/factions/commands/FBaseCommand.java b/src/org/mcteam/factions/commands/FBaseCommand.java index 12654dd1..3ab5da5b 100644 --- a/src/org/mcteam/factions/commands/FBaseCommand.java +++ b/src/org/mcteam/factions/commands/FBaseCommand.java @@ -86,7 +86,7 @@ public class FBaseCommand { } if (parameters.size() < requiredParameters.size()) { - sendMessage("Usage: "+this.getUseageTemplate(true)); + sendMessage("Usage: "+this.getUseageTemplate(false)); return false; } @@ -97,35 +97,14 @@ public class FBaseCommand { 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 // -------------------------------------------- // - public String getUseageTemplate(boolean withColor, boolean withDescription) { + + public String getUseageTemplate(boolean withDescription) { String ret = ""; - if (withColor) { - ret += Conf.colorCommand; - } + ret += Conf.colorCommand; ret += Factions.instance.getBaseCommand()+ " " +TextUtil.implode(this.getAliases(), ",")+" "; @@ -139,9 +118,7 @@ public class FBaseCommand { parts.add("*["+optionalParameter+"]"); } - if (withColor) { - ret += Conf.colorParameter; - } + ret += Conf.colorParameter; ret += TextUtil.implode(parts, " "); @@ -151,10 +128,6 @@ public class FBaseCommand { return ret; } - public String getUseageTemplate(boolean withColor) { - return getUseageTemplate(withColor, false); - } - public String getUseageTemplate() { return getUseageTemplate(true); } diff --git a/src/org/mcteam/factions/commands/FCommandBypass.java b/src/org/mcteam/factions/commands/FCommandBypass.java index 677b8e48..b0f0ccbd 100644 --- a/src/org/mcteam/factions/commands/FCommandBypass.java +++ b/src/org/mcteam/factions/commands/FCommandBypass.java @@ -1,11 +1,9 @@ package org.mcteam.factions.commands; 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 { diff --git a/src/org/mcteam/factions/commands/FCommandCreate.java b/src/org/mcteam/factions/commands/FCommandCreate.java index a91f1715..e5a64ba9 100644 --- a/src/org/mcteam/factions/commands/FCommandCreate.java +++ b/src/org/mcteam/factions/commands/FCommandCreate.java @@ -53,7 +53,7 @@ public class FCommandCreate extends FBaseCommand { 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()); } } diff --git a/src/org/mcteam/factions/commands/FCommandDeinvite.java b/src/org/mcteam/factions/commands/FCommandDeinvite.java index 12648cdf..59a1f5d4 100644 --- a/src/org/mcteam/factions/commands/FCommandDeinvite.java +++ b/src/org/mcteam/factions/commands/FCommandDeinvite.java @@ -36,7 +36,7 @@ public class FCommandDeinvite extends FBaseCommand { if (you.getFaction() == myFaction) { 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; } diff --git a/src/org/mcteam/factions/commands/FCommandHelp.java b/src/org/mcteam/factions/commands/FCommandHelp.java index 47dd8b66..10510d06 100644 --- a/src/org/mcteam/factions/commands/FCommandHelp.java +++ b/src/org/mcteam/factions/commands/FCommandHelp.java @@ -52,45 +52,45 @@ public class FCommandHelp extends FBaseCommand { ArrayList pageLines; pageLines = new ArrayList(); - pageLines.add( new FCommandHelp().getUseageTemplate(true, true) ); - pageLines.add( new FCommandList().getUseageTemplate(true, true) ); - pageLines.add( new FCommandShow().getUseageTemplate(true, true) ); - pageLines.add( new FCommandMap().getUseageTemplate(true, true) ); - pageLines.add( new FCommandJoin().getUseageTemplate(true, true) ); - pageLines.add( new FCommandLeave().getUseageTemplate(true, true) ); - pageLines.add( new FCommandChat().getUseageTemplate(true, true) ); - pageLines.add( new FCommandHome().getUseageTemplate(true, true) ); + pageLines.add( new FCommandHelp().getUseageTemplate() ); + pageLines.add( new FCommandList().getUseageTemplate() ); + pageLines.add( new FCommandShow().getUseageTemplate() ); + pageLines.add( new FCommandMap().getUseageTemplate() ); + pageLines.add( new FCommandJoin().getUseageTemplate() ); + pageLines.add( new FCommandLeave().getUseageTemplate() ); + pageLines.add( new FCommandChat().getUseageTemplate() ); + pageLines.add( new FCommandHome().getUseageTemplate() ); pageLines.add( "Learn how to create a faction on the next page." ); helpPages.add(pageLines); pageLines = new ArrayList(); pageLines.add( "Create a faction using these two commands:" ); - pageLines.add( new FCommandCreate().getUseageTemplate(true, true) ); - pageLines.add( new FCommandDescription().getUseageTemplate(true, true) ); + pageLines.add( new FCommandCreate().getUseageTemplate() ); + pageLines.add( new FCommandDescription().getUseageTemplate() ); pageLines.add( "You might wan't to close it and use invitations:" ); - pageLines.add( new FCommandOpen().getUseageTemplate(true, true) ); - pageLines.add( new FCommandInvite().getUseageTemplate(true, true) ); - pageLines.add( new FCommandDeinvite().getUseageTemplate(true, true) ); + pageLines.add( new FCommandOpen().getUseageTemplate() ); + pageLines.add( new FCommandInvite().getUseageTemplate() ); + pageLines.add( new FCommandDeinvite().getUseageTemplate() ); 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); pageLines = new ArrayList(); pageLines.add( "Faction can claim land that will be protected." ); - pageLines.add( new FCommandClaim().getUseageTemplate(true, true) ); - pageLines.add( new FCommandUnclaim().getUseageTemplate(true, true) ); - pageLines.add( new FCommandTag().getUseageTemplate(true, true) ); - pageLines.add( new FCommandKick().getUseageTemplate(true, true) ); - pageLines.add( new FCommandMod().getUseageTemplate(true, true) ); - pageLines.add( new FCommandAdmin().getUseageTemplate(true, true) ); - pageLines.add( new FCommandTitle().getUseageTemplate(true, true) ); + pageLines.add( new FCommandClaim().getUseageTemplate() ); + pageLines.add( new FCommandUnclaim().getUseageTemplate() ); + pageLines.add( new FCommandTag().getUseageTemplate() ); + pageLines.add( new FCommandKick().getUseageTemplate() ); + pageLines.add( new FCommandMod().getUseageTemplate() ); + pageLines.add( new FCommandAdmin().getUseageTemplate() ); + pageLines.add( new FCommandTitle().getUseageTemplate() ); pageLines.add( "Player titles are just for fun. No rules connected to them." ); helpPages.add(pageLines); pageLines = new ArrayList(); - pageLines.add( new FCommandRelationAlly().getUseageTemplate(true, true) ); - pageLines.add( new FCommandRelationNeutral().getUseageTemplate(true, true) ); - pageLines.add( new FCommandRelationEnemy().getUseageTemplate(true, true) ); + pageLines.add( new FCommandRelationAlly().getUseageTemplate() ); + pageLines.add( new FCommandRelationNeutral().getUseageTemplate() ); + pageLines.add( new FCommandRelationEnemy().getUseageTemplate() ); pageLines.add(""); pageLines.add("Set the relation you WISH to have with another faction."); pageLines.add("Your default relation with other factions will be neutral."); @@ -125,9 +125,9 @@ public class FCommandHelp extends FBaseCommand { pageLines = new ArrayList(); pageLines.add("Finally some commands for the server admins:"); - pageLines.add( new FCommandVersion().getUseageTemplate(true, true) ); - pageLines.add( new FCommandSafeclaim().getUseageTemplate(true, true) ); - pageLines.add( new FCommandBypass().getUseageTemplate(true, true) ); + pageLines.add( new FCommandVersion().getUseageTemplate() ); + pageLines.add( new FCommandSafeclaim().getUseageTemplate() ); + pageLines.add( new FCommandBypass().getUseageTemplate() ); helpPages.add(pageLines); } diff --git a/src/org/mcteam/factions/commands/FCommandHome.java b/src/org/mcteam/factions/commands/FCommandHome.java index be91911e..f15fc8c7 100644 --- a/src/org/mcteam/factions/commands/FCommandHome.java +++ b/src/org/mcteam/factions/commands/FCommandHome.java @@ -26,7 +26,7 @@ public class FCommandHome extends FBaseCommand { 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(new FCommandSethome().getUseageTemplate(true, true)); + me.sendMessage(new FCommandSethome().getUseageTemplate()); return; } diff --git a/src/org/mcteam/factions/commands/FCommandInvite.java b/src/org/mcteam/factions/commands/FCommandInvite.java index 27437bbe..673e29c7 100644 --- a/src/org/mcteam/factions/commands/FCommandInvite.java +++ b/src/org/mcteam/factions/commands/FCommandInvite.java @@ -36,7 +36,7 @@ public class FCommandInvite extends FBaseCommand { if (you.getFaction() == myFaction) { 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; } diff --git a/src/org/mcteam/factions/commands/FCommandKick.java b/src/org/mcteam/factions/commands/FCommandKick.java index c673ce97..c19b72a3 100644 --- a/src/org/mcteam/factions/commands/FCommandKick.java +++ b/src/org/mcteam/factions/commands/FCommandKick.java @@ -31,7 +31,7 @@ public class FCommandKick extends FBaseCommand { if (me == you) { sendMessage("You cannot kick yourself."); - sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate()); + sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate(false)); return; } diff --git a/src/org/mcteam/factions/commands/FCommandSethome.java b/src/org/mcteam/factions/commands/FCommandSethome.java index 814ff57b..0ee79724 100644 --- a/src/org/mcteam/factions/commands/FCommandSethome.java +++ b/src/org/mcteam/factions/commands/FCommandSethome.java @@ -32,7 +32,7 @@ public class FCommandSethome extends FBaseCommand { myFaction.setHome(player.getLocation()); 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()); } }