From 3981ca4dde28991d1df03e6620574415d2ff70c0 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sat, 15 Oct 2011 12:46:09 -0500 Subject: [PATCH 1/3] Added fence gates to default "territoryProtectedMaterials" list. Existing users should run these commands to add it to an existing config, if desired: /f config territoryProtectedMaterials FENCE_GATE /f config territoryProtectedMaterialsWhenOffline FENCE_GATE Also changed first letter of "canLeaveWithNegativePower" setting to lowercase, to fit with Java standards. If you had previously changed this setting to false, you'll need to do so again. --- src/com/massivecraft/factions/Conf.java | 4 +++- src/com/massivecraft/factions/FPlayer.java | 2 +- src/com/massivecraft/factions/cmd/CmdJoin.java | 2 +- src/com/massivecraft/factions/cmd/CmdKick.java | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 6fd86426..273a60db 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -43,7 +43,7 @@ public class Conf public static boolean showEnemyFactionsOnMap = true; // Disallow joining/leaving/kicking while power is negative - public static boolean CanLeaveWithNegativePower = true; + public static boolean canLeaveWithNegativePower = true; // Configuration for faction-only chat public static boolean factionOnlyChat = true; @@ -250,6 +250,7 @@ public class Conf territoryProtectedMaterials.add(Material.WOODEN_DOOR); territoryProtectedMaterials.add(Material.TRAP_DOOR); + territoryProtectedMaterials.add(Material.FENCE_GATE); territoryProtectedMaterials.add(Material.DISPENSER); territoryProtectedMaterials.add(Material.CHEST); territoryProtectedMaterials.add(Material.FURNACE); @@ -264,6 +265,7 @@ public class Conf territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR); territoryProtectedMaterialsWhenOffline.add(Material.TRAP_DOOR); + territoryProtectedMaterialsWhenOffline.add(Material.FENCE_GATE); territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER); territoryProtectedMaterialsWhenOffline.add(Material.CHEST); territoryProtectedMaterialsWhenOffline.add(Material.FURNACE); diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index b717fbab..3da00e0b 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -577,7 +577,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator return; } - if (!Conf.CanLeaveWithNegativePower && this.getPower() < 0) + if (!Conf.canLeaveWithNegativePower && this.getPower() < 0) { msg("You cannot leave until your power is positive."); return; diff --git a/src/com/massivecraft/factions/cmd/CmdJoin.java b/src/com/massivecraft/factions/cmd/CmdJoin.java index 961d2c5c..6fccc08f 100644 --- a/src/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdJoin.java @@ -47,7 +47,7 @@ public class CmdJoin extends FCommand return; } - if (!Conf.CanLeaveWithNegativePower && fme.getPower() < 0) + if (!Conf.canLeaveWithNegativePower && fme.getPower() < 0) { msg("You cannot join a faction until your power is positive."); return; diff --git a/src/com/massivecraft/factions/cmd/CmdKick.java b/src/com/massivecraft/factions/cmd/CmdKick.java index e1e953d7..7880314e 100644 --- a/src/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/com/massivecraft/factions/cmd/CmdKick.java @@ -57,7 +57,7 @@ public class CmdKick extends FCommand return; } - if ( ! Conf.CanLeaveWithNegativePower && you.getPower() < 0) + if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0) { msg("You cannot kick that member until their power is positive."); return; From 61bd37c99b448ce31f88e1f6b8c2fc168bc7a45c Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sat, 15 Oct 2011 12:46:44 -0500 Subject: [PATCH 2/3] A bit of command help menu cleanup --- src/com/massivecraft/factions/cmd/CmdAutoClaim.java | 2 +- src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java | 2 +- src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java | 6 ++---- src/com/massivecraft/factions/cmd/CmdBoom.java | 2 +- src/com/massivecraft/factions/cmd/CmdBypass.java | 2 +- src/com/massivecraft/factions/cmd/CmdHelp.java | 2 -- src/com/massivecraft/factions/cmd/CmdLock.java | 2 +- src/com/massivecraft/factions/cmd/CmdOpen.java | 2 +- src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java | 2 +- src/com/massivecraft/factions/integration/Econ.java | 2 +- 10 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdAutoClaim.java b/src/com/massivecraft/factions/cmd/CmdAutoClaim.java index cd45cf8e..ca687029 100644 --- a/src/com/massivecraft/factions/cmd/CmdAutoClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdAutoClaim.java @@ -12,7 +12,7 @@ public class CmdAutoClaim extends FCommand this.aliases.add("autoclaim"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flipp"); + this.optionalArgs.put("on/off", "flip"); this.permission = Permission.AUTOCLAIM.node; this.disableOnLock = true; diff --git a/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java b/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java index bf87439c..f7ed9810 100644 --- a/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java @@ -14,7 +14,7 @@ public class CmdAutoSafeclaim extends FCommand this.aliases.add("autosafe"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flipp"); + this.optionalArgs.put("on/off", "flip"); this.permission = Permission.MANAGE_SAFE_ZONE.node; this.disableOnLock = true; diff --git a/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java b/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java index 33142f3e..a58e459c 100644 --- a/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java @@ -12,10 +12,10 @@ public class CmdAutoWarclaim extends FCommand public CmdAutoWarclaim() { super(); - this.aliases.add("autosafe"); + aliases.add("autowar"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flipp"); + this.optionalArgs.put("on/off", "flip"); this.permission = Permission.MANAGE_WAR_ZONE.node; this.disableOnLock = true; @@ -24,8 +24,6 @@ public class CmdAutoWarclaim extends FCommand senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false; - - aliases.add("autowar"); this.setHelpShort("Auto-claim land for the warzone"); } diff --git a/src/com/massivecraft/factions/cmd/CmdBoom.java b/src/com/massivecraft/factions/cmd/CmdBoom.java index 1f83c964..d3319bc3 100644 --- a/src/com/massivecraft/factions/cmd/CmdBoom.java +++ b/src/com/massivecraft/factions/cmd/CmdBoom.java @@ -11,7 +11,7 @@ public class CmdBoom extends FCommand this.aliases.add("noboom"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flipp"); + this.optionalArgs.put("on/off", "flip"); this.permission = Permission.NO_BOOM.node; this.disableOnLock = true; diff --git a/src/com/massivecraft/factions/cmd/CmdBypass.java b/src/com/massivecraft/factions/cmd/CmdBypass.java index d9ba4abd..5e626d60 100644 --- a/src/com/massivecraft/factions/cmd/CmdBypass.java +++ b/src/com/massivecraft/factions/cmd/CmdBypass.java @@ -11,7 +11,7 @@ public class CmdBypass extends FCommand this.aliases.add("bypass"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flipp"); + this.optionalArgs.put("on/off", "flip"); this.permission = Permission.BYPASS.node; this.disableOnLock = false; diff --git a/src/com/massivecraft/factions/cmd/CmdHelp.java b/src/com/massivecraft/factions/cmd/CmdHelp.java index a60a7c94..0f334a73 100644 --- a/src/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/com/massivecraft/factions/cmd/CmdHelp.java @@ -113,10 +113,8 @@ public class CmdHelp extends FCommand pageLines = new ArrayList(); pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdBoom.getUseageTemplate(true) ); - pageLines.add(""); pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate(true) ); - pageLines.add(""); pageLines.add(p.txt.parse("Claimed land with ownership set is further protected so")); pageLines.add(p.txt.parse("that only the owner(s), faction admin, and possibly the")); pageLines.add(p.txt.parse("faction moderators have full access.")); diff --git a/src/com/massivecraft/factions/cmd/CmdLock.java b/src/com/massivecraft/factions/cmd/CmdLock.java index d811d0a6..16d4206e 100644 --- a/src/com/massivecraft/factions/cmd/CmdLock.java +++ b/src/com/massivecraft/factions/cmd/CmdLock.java @@ -17,7 +17,7 @@ public class CmdLock extends FCommand { this.aliases.add("lock"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flipp"); + this.optionalArgs.put("on/off", "flip"); this.permission = Permission.LOCK.node; this.disableOnLock = false; diff --git a/src/com/massivecraft/factions/cmd/CmdOpen.java b/src/com/massivecraft/factions/cmd/CmdOpen.java index 9397aa37..4b0bbb02 100644 --- a/src/com/massivecraft/factions/cmd/CmdOpen.java +++ b/src/com/massivecraft/factions/cmd/CmdOpen.java @@ -13,7 +13,7 @@ public class CmdOpen extends FCommand this.aliases.add("open"); //this.requiredArgs.add(""); - this.optionalArgs.put("yes/no", "flipp"); + this.optionalArgs.put("yes/no", "flip"); this.permission = Permission.OPEN.node; this.disableOnLock = false; diff --git a/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java b/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java index 415ffeaa..16cc36e5 100644 --- a/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java @@ -13,7 +13,7 @@ public class CmdSafeunclaimall extends FCommand this.aliases.add("safedeclaimall"); //this.requiredArgs.add(""); - this.optionalArgs.put("radius", "0"); + //this.optionalArgs.put("radius", "0"); this.permission = Permission.MANAGE_SAFE_ZONE.node; this.disableOnLock = true; diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index 5e3e5eb8..18bf2e64 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -58,7 +58,7 @@ public class Econ } else { - P.p.log("Economy integration failed. The plugin \"Register\" is not installed."); + P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Register\" is not installed."); } P.p.cmdBase.cmdHelp.updateHelp(); From f5450886f10ce6c75306ac82f91583808ece91bd Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sun, 16 Oct 2011 04:02:29 -0500 Subject: [PATCH 3/3] Fix for Bukkit "unknown command" error when using console commands handling for extra commas in "baseCommandAliases" in conf.json adding null values --- plugin.yml | 4 ++++ .../massivecraft/factions/cmd/FCmdRoot.java | 3 +++ .../zcore/MPluginSecretServerListener.java | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/plugin.yml b/plugin.yml index e50c05e5..1a2d9f80 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,6 +3,10 @@ version: 1.6.0_dev main: com.massivecraft.factions.P authors: [Olof Larsson, Brett Flannigan] softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, nChat, ChatManager, CAPI, AuthMe, Register, Spout, WorldEdit, WorldGuard] +commands: + factions: + description: Reference command for Factions. + aliases: [f] permissions: factions.kit.admin: description: All faction permissions. diff --git a/src/com/massivecraft/factions/cmd/FCmdRoot.java b/src/com/massivecraft/factions/cmd/FCmdRoot.java index 8babf412..52e1a22d 100644 --- a/src/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/com/massivecraft/factions/cmd/FCmdRoot.java @@ -1,5 +1,7 @@ package com.massivecraft.factions.cmd; +import java.util.Collections; + import com.massivecraft.factions.Conf; public class FCmdRoot extends FCommand @@ -55,6 +57,7 @@ public class FCmdRoot extends FCommand { super(); this.aliases.addAll(Conf.baseCommandAliases); + this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas this.allowNoSlashAccess = Conf.allowNoSlashCommand; //this.requiredArgs.add(""); diff --git a/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java b/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java index b51a2ae8..90e62220 100644 --- a/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java +++ b/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java @@ -1,17 +1,31 @@ package com.massivecraft.factions.zcore; +import java.util.Map; + import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerListener; public class MPluginSecretServerListener extends ServerListener { private MPlugin p; + private String refCommand; + public MPluginSecretServerListener(MPlugin p) { this.p = p; + refCommand = ""; + + // attempt to get first command defined in plugin.yml as reference command, if any commands are defined in there + // reference command will be used to prevent "unknown command" console messages + try + { + Map refCmd = (Map) p.getDescription().getCommands(); + if (refCmd != null && !refCmd.isEmpty()) + refCommand = (String)(refCmd.keySet().toArray()[0]); + } + catch (ClassCastException ex) {} } - // This method is not perfect. It says unknown console command. @Override public void onServerCommand(ServerCommandEvent event) { @@ -19,7 +33,7 @@ public class MPluginSecretServerListener extends ServerListener if (p.handleCommand(event.getSender(), event.getCommand())) { - event.setCommand(""); + event.setCommand(refCommand); } }