diff --git a/src/main/java/com/massivecraft/factions/Perm.java b/src/main/java/com/massivecraft/factions/Perm.java index 1a7ffd90..9eed2237 100644 --- a/src/main/java/com/massivecraft/factions/Perm.java +++ b/src/main/java/com/massivecraft/factions/Perm.java @@ -26,6 +26,7 @@ public enum Perm FLAG("flag"), FLAG_SET("flag.set"), HOME("home"), + HOME_OTHER("home.other"), INVITE("invite"), JOIN("join"), JOIN_ANY("join.any"), @@ -59,6 +60,8 @@ public enum Perm TITLE_COLOR("title.color"), UNCLAIM("unclaim"), UNCLAIM_ALL("unclaimall"), + UNSETHOME("unsethome"), + UNSETHOME_OTHER("unsethome.other"), VERSION("version"), // END OF LIST diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java index 32f84adb..f958e7a1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java @@ -8,7 +8,7 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.massivecore.cmd.HelpCommand; import com.massivecraft.massivecore.cmd.VersionCommand; -public class CmdFactions extends FCommand +public class CmdFactions extends FactionsCommand { // -------------------------------------------- // // FIELDS @@ -25,6 +25,7 @@ public class CmdFactions extends FCommand public CmdFactionsName cmdFactionsName = new CmdFactionsName(); public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription(); public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome(); + public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome(); public CmdFactionsOpen cmdFactionsOpen = new CmdFactionsOpen(); public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite(); public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick(); @@ -57,7 +58,7 @@ public class CmdFactions extends FCommand public CmdFactions() { - // Add SubCommands + // SubCommands this.addSubCommand(HelpCommand.get()); this.addSubCommand(this.cmdFactionsList); this.addSubCommand(this.cmdFactionsFaction); @@ -70,6 +71,7 @@ public class CmdFactions extends FCommand this.addSubCommand(this.cmdFactionsName); this.addSubCommand(this.cmdFactionsDescription); this.addSubCommand(this.cmdFactionsSethome); + this.addSubCommand(this.cmdFactionsUnsethome); this.addSubCommand(this.cmdFactionsOpen); this.addSubCommand(this.cmdFactionsInvite); this.addSubCommand(this.cmdFactionsKick); @@ -95,10 +97,6 @@ public class CmdFactions extends FCommand this.addSubCommand(this.cmdFactionsAdmin); this.addSubCommand(this.cmdFactionsPowerBoost); this.addSubCommand(this.cmdFactionsVersion); - - // Misc - this.setDesc("The faction base command"); - this.setHelp("This command contains all faction stuff."); } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java index 7c2c4027..102e6c94 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java @@ -6,7 +6,7 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; -public class CmdFactionsAccess extends FCommand +public class CmdFactionsAccess extends FactionsCommand { // -------------------------------------------- // // FIELDS diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java index 9ccf742e..22e14b09 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java @@ -14,7 +14,7 @@ import com.massivecraft.massivecore.ps.PSFormatHumanSpace; import com.massivecraft.massivecore.util.Txt; -public abstract class CmdFactionsAccessAbstract extends FCommand +public abstract class CmdFactionsAccessAbstract extends FactionsCommand { // -------------------------------------------- // // FIELDS @@ -53,10 +53,10 @@ public abstract class CmdFactionsAccessAbstract extends FCommand public void sendAccessInfo() { sendMessage(Txt.titleize("Access at " + chunk.toString(PSFormatHumanSpace.get()))); - msg("Host Faction: %s", hostFaction.describeTo(usender, true)); + msg("Host Faction: %s", hostFaction.describeTo(msender, true)); msg("Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("TRUE") : Txt.parse("FALSE")); - msg("Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), usender)); - msg("Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), usender)); + msg("Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender)); + msg("Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), msender)); } public static String describeRelationParticipators(Collection relationParticipators, RelationParticipator observer) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java index 9d04ada7..e6b57dc9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java @@ -42,7 +42,7 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract if (newValue == null) return; // FPerm - if (!FPerm.ACCESS.has(usender, hostFaction, true)) return; + if (!FPerm.ACCESS.has(msender, hostFaction, true)) return; // Apply ta = ta.withFactionId(faction.getId(), newValue); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java index 56944866..4abf18ce 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java @@ -42,7 +42,7 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract if (newValue == null) return; // FPerm - if (!FPerm.ACCESS.has(usender, hostFaction, true)) return; + if (!FPerm.ACCESS.has(msender, hostFaction, true)) return; // Apply ta = ta.withPlayerId(mplayer.getId(), newValue); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java index c0199338..1b8adbc7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java @@ -5,7 +5,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsAdmin extends FCommand +public class CmdFactionsAdmin extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java index f5260233..9ae49dad 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java @@ -8,7 +8,7 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsAutoClaim extends FCommand +public class CmdFactionsAutoClaim extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -35,22 +35,22 @@ public class CmdFactionsAutoClaim extends FCommand public void perform() { // Args - Faction forFaction = this.arg(0, ARFaction.get(), usenderFaction); + Faction forFaction = this.arg(0, ARFaction.get(), msenderFaction); - if (forFaction == null || forFaction == usender.getAutoClaimFaction()) + if (forFaction == null || forFaction == msender.getAutoClaimFaction()) { - usender.setAutoClaimFaction(null); + msender.setAutoClaimFaction(null); msg("Auto-claiming of land disabled."); return; } // FPerm - if (forFaction.isNormal() && !FPerm.TERRITORY.has(usender, forFaction, true)) return; + if (forFaction.isNormal() && !FPerm.TERRITORY.has(msender, forFaction, true)) return; - usender.setAutoClaimFaction(forFaction); + msender.setAutoClaimFaction(forFaction); - msg("Now auto-claiming land for %s.", forFaction.describeTo(usender)); - usender.tryClaim(forFaction, PS.valueOf(me), true, true); + msg("Now auto-claiming land for %s.", forFaction.describeTo(msender)); + msender.tryClaim(forFaction, PS.valueOf(me), true, true); } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java index b2a044d2..ef1e4c49 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -12,7 +12,7 @@ import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsClaim extends FCommand +public class CmdFactionsClaim extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -43,11 +43,11 @@ public class CmdFactionsClaim extends FCommand Integer radius = this.arg(0, ARInteger.get(), 1); if (radius == null) return; - final Faction forFaction = this.arg(1, ARFaction.get(), usenderFaction); + final Faction forFaction = this.arg(1, ARFaction.get(), msenderFaction); if (forFaction == null) return; // FPerm - if (forFaction.isNormal() && !FPerm.TERRITORY.has(usender, forFaction, true)) return; + if (forFaction.isNormal() && !FPerm.TERRITORY.has(msender, forFaction, true)) return; // Validate if (radius < 1) @@ -56,7 +56,7 @@ public class CmdFactionsClaim extends FCommand return; } - if (radius > MConf.get().radiusClaimRadiusLimit && !usender.isUsingAdminMode()) + if (radius > MConf.get().radiusClaimRadiusLimit && !msender.isUsingAdminMode()) { msg("The maximum radius allowed is %s.", MConf.get().radiusClaimRadiusLimit); return; @@ -67,7 +67,7 @@ public class CmdFactionsClaim extends FCommand // single chunk if (radius < 2) { - usender.tryClaim(forFaction, PS.valueOf(me), true, true); + msender.tryClaim(forFaction, PS.valueOf(me), true, true); return; } @@ -91,7 +91,7 @@ public class CmdFactionsClaim extends FCommand @Override public boolean work() { - boolean success = usender.tryClaim(forFaction, PS.valueOf(this.currentLocation()), true, true); + boolean success = msender.tryClaim(forFaction, PS.valueOf(this.currentLocation()), true, true); if (success) { this.failCount = 0; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java index c49c981a..15121264 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java @@ -17,7 +17,7 @@ import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipC import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.store.MStore; -public class CmdFactionsCreate extends FCommand +public class CmdFactionsCreate extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -72,24 +72,24 @@ public class CmdFactionsCreate extends FCommand Faction faction = FactionColl.get().create(factionId); faction.setName(newName); - usender.setRole(Rel.LEADER); - usender.setFaction(faction); + msender.setRole(Rel.LEADER); + msender.setFaction(faction); - EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, usender, faction, MembershipChangeReason.CREATE); + EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE); joinEvent.run(); // NOTE: join event cannot be cancelled or you'll have an empty faction // Inform for (MPlayer follower : MPlayerColl.get().getAllOnline()) { - follower.msg("%s created a new faction %s", usender.describeTo(follower, true), faction.getName(follower)); + follower.msg("%s created a new faction %s", msender.describeTo(follower, true), faction.getName(follower)); } msg("You should now: %s", Factions.get().getOuterCmdFactions().cmdFactionsDescription.getUseageTemplate()); if (MConf.get().logFactionCreate) { - Factions.get().log(usender.getName()+" created a new faction: "+newName); + Factions.get().log(msender.getName()+" created a new faction: "+newName); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java index 5622fc21..e8cda4e9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java @@ -6,7 +6,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsDemote extends FCommand +public class CmdFactionsDemote extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -38,13 +38,13 @@ public class CmdFactionsDemote extends FCommand MPlayer you = this.arg(0, ARMPlayer.getAny()); if (you == null) return; - if (you.getFaction() != usenderFaction) + if (you.getFaction() != msenderFaction) { - msg("%s is not a member in your faction.", you.describeTo(usender, true)); + msg("%s is not a member in your faction.", you.describeTo(msender, true)); return; } - if (you == usender) + if (you == msender) { msg("The target player mustn't be yourself."); return; @@ -52,23 +52,23 @@ public class CmdFactionsDemote extends FCommand if (you.getRole() == Rel.MEMBER) { - if (!usender.getRole().isAtLeast(Rel.OFFICER)) + if (!msender.getRole().isAtLeast(Rel.OFFICER)) { msg("You must be an officer to demote a member to recruit."); return; } you.setRole(Rel.RECRUIT); - usenderFaction.msg("%s was demoted to being a recruit in your faction.", you.describeTo(usenderFaction, true)); + msenderFaction.msg("%s was demoted to being a recruit in your faction.", you.describeTo(msenderFaction, true)); } else if (you.getRole() == Rel.OFFICER) { - if (!usender.getRole().isAtLeast(Rel.LEADER)) + if (!msender.getRole().isAtLeast(Rel.LEADER)) { msg("You must be the leader to demote an officer to member."); return; } you.setRole(Rel.MEMBER); - usenderFaction.msg("%s was demoted to being a member in your faction.", you.describeTo(usenderFaction, true)); + msenderFaction.msg("%s was demoted to being a member in your faction.", you.describeTo(msenderFaction, true)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java index ecdf7579..b758242a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java @@ -9,7 +9,7 @@ import com.massivecraft.factions.event.EventFactionsDescriptionChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.mixin.Mixin; -public class CmdFactionsDescription extends FCommand +public class CmdFactionsDescription extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -41,18 +41,18 @@ public class CmdFactionsDescription extends FCommand String newDescription = this.argConcatFrom(0); // Event - EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, usenderFaction, newDescription); + EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, msenderFaction, newDescription); event.run(); if (event.isCancelled()) return; newDescription = event.getNewDescription(); // Apply - usenderFaction.setDescription(newDescription); + msenderFaction.setDescription(newDescription); // Inform - for (MPlayer follower : usenderFaction.getMPlayers()) + for (MPlayer follower : msenderFaction.getMPlayers()) { - follower.msg("%s set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), usenderFaction.getDescription()); + follower.msg("%s set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), msenderFaction.getDescription()); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java index 38410c8c..753b4743 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -17,7 +17,7 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsDisband extends FCommand +public class CmdFactionsDisband extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -43,11 +43,11 @@ public class CmdFactionsDisband extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; // FPerm - if ( ! FPerm.DISBAND.has(usender, faction, true)) return; + if ( ! FPerm.DISBAND.has(msender, faction, true)) return; // Verify if (faction.getFlag(FFlag.PERMANENT)) @@ -73,7 +73,7 @@ public class CmdFactionsDisband extends FCommand // Inform all players for (MPlayer mplayer : MPlayerColl.get().getAllOnline()) { - String who = usender.describeTo(mplayer); + String who = msender.describeTo(mplayer); if (mplayer.getFaction() == faction) { mplayer.msg("%s disbanded your faction.", who); @@ -86,7 +86,7 @@ public class CmdFactionsDisband extends FCommand if (MConf.get().logFactionDisband) { - Factions.get().log(Txt.parse("The faction %s (%s) was disbanded by %s.", faction.getName(), faction.getId(), usender.getDisplayName(IdUtil.getConsole()))); + Factions.get().log(Txt.parse("The faction %s (%s) was disbanded by %s.", faction.getName(), faction.getId(), msender.getDisplayName(IdUtil.getConsole()))); } faction.detach(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java index 4bcddf87..78c0a4bc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java @@ -23,7 +23,7 @@ import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsFaction extends FCommand +public class CmdFactionsFaction extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -49,7 +49,7 @@ public class CmdFactionsFaction extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; // Data precalculation @@ -57,7 +57,7 @@ public class CmdFactionsFaction extends FCommand boolean normal = faction.isNormal(); // INFO: Title - msg(Txt.titleize("Faction " + faction.getName(usender))); + msg(Txt.titleize("Faction " + faction.getName(msender))); // INFO: Description msg("Description: %s", faction.getDescription()); @@ -127,7 +127,7 @@ public class CmdFactionsFaction extends FCommand String sepparator = Txt.parse("")+", "; // List the relations to other factions - Map> relationNames = faction.getFactionNamesPerRelation(usender, true); + Map> relationNames = faction.getFactionNamesPerRelation(msender, true); if (faction.getFlag(FFlag.PEACEFUL)) { @@ -152,12 +152,12 @@ public class CmdFactionsFaction extends FCommand { if (follower.isOnline() && Mixin.canSee(sender, follower.getId())) { - followerNamesOnline.add(follower.getNameAndTitle(usender)); + followerNamesOnline.add(follower.getNameAndTitle(msender)); } else if (normal) { // For the non-faction we skip the offline members since they are far to many (infinate almost) - followerNamesOffline.add(follower.getNameAndTitle(usender)); + followerNamesOffline.add(follower.getNameAndTitle(msender)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java index 669be843..b31379e8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java @@ -9,7 +9,7 @@ import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsFlag extends FCommand +public class CmdFactionsFlag extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -36,12 +36,12 @@ public class CmdFactionsFlag extends FCommand @Override public void perform() { - Faction faction = this.arg(0, ARFaction.get(), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; if ( ! this.argIsSet(1)) { - msg(Txt.titleize("Flags for " + faction.describeTo(usender, true))); + msg(Txt.titleize("Flags for " + faction.describeTo(msender, true))); for (FFlag flag : FFlag.values()) { msg(flag.getStateInfo(faction.getFlag(flag), true)); @@ -54,7 +54,7 @@ public class CmdFactionsFlag extends FCommand if ( ! this.argIsSet(2)) { - msg(Txt.titleize("Flag for " + faction.describeTo(usender, true))); + msg(Txt.titleize("Flag for " + faction.describeTo(msender, true))); msg(flag.getStateInfo(faction.getFlag(flag), true)); return; } @@ -66,7 +66,7 @@ public class CmdFactionsFlag extends FCommand if ( ! Perm.FLAG_SET.has(sender, true)) return; // Do the change - msg(Txt.titleize("Flag for " + faction.describeTo(usender, true))); + msg(Txt.titleize("Flag for " + faction.describeTo(msender, true))); faction.setFlag(flag, targetValue); msg(flag.getStateInfo(faction.getFlag(flag), true)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java index 0ebdbc3a..4a1c276a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -5,10 +5,11 @@ import org.bukkit.World; import org.bukkit.entity.Player; import com.massivecraft.factions.FFlag; +import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqHasFaction; +import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; @@ -21,7 +22,7 @@ import com.massivecraft.massivecore.mixin.TeleporterException; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsHome extends FCommand +public class CmdFactionsHome extends FactionsCommandHome { // -------------------------------------------- // // CONSTRUCT @@ -31,13 +32,15 @@ public class CmdFactionsHome extends FCommand { // Aliases this.addAliases("home"); + + // Args + this.addOptionalArg("faction", "you"); // Requirements this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); - this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); } - + // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @@ -45,64 +48,73 @@ public class CmdFactionsHome extends FCommand @Override public void perform() { - // TODO: Hide this command on help also. - if ( ! MConf.get().homesEnabled) - { - usender.msg("Sorry, Faction homes are disabled on this server."); - return; - } - if ( ! MConf.get().homesTeleportCommandEnabled) { - usender.msg("Sorry, the ability to teleport to Faction homes is disabled on this server."); + msender.msg("Sorry, the ability to teleport to Faction homes is disabled on this server."); return; } - if ( ! usenderFaction.hasHome()) + // Args + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); + if (faction == null) return; + boolean other = faction != msenderFaction; + PS home = faction.getHome(); + String homeDesc = "home for " + faction.describeTo(msender, false); + + // Other Perm + if (other && !Perm.HOME_OTHER.has(sender, true)) return; + + if (home == null) { - usender.msg("Your faction does not have a home. " + (usender.getRole().isLessThan(Rel.OFFICER) ? " Ask your leader to:" : "You should:")); - usender.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getUseageTemplate()); + msender.msg("%s does not have a home.", faction.describeTo(msender, true)); + + if (FPerm.SETHOME.has(msender, faction, false)) + { + msender.msg("You should:"); + msender.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getUseageTemplate()); + } + return; } - if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && usender.isInEnemyTerritory()) + if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory()) { - usender.msg("You cannot teleport to your faction home while in the territory of an enemy faction."); + msender.msg("You cannot teleport to %s while in the territory of an enemy faction.", homeDesc); return; } - if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(usenderFaction.getHome().getWorld())) + if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(home.getWorld())) { - usender.msg("You cannot teleport to your faction home while in a different world."); + msender.msg("You cannot teleport to %s while in a different world.", homeDesc); return; } - Faction faction = BoardColl.get().getFactionAt(PS.valueOf(me)); - Location loc = me.getLocation().clone(); + Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me)); + Location locationHere = me.getLocation().clone(); // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby if ( MConf.get().homesTeleportAllowedEnemyDistance > 0 && - faction.getFlag(FFlag.PVP) + factionHere.getFlag(FFlag.PVP) && ( - ! usender.isInOwnTerritory() + ! msender.isInOwnTerritory() || ( - usender.isInOwnTerritory() + msender.isInOwnTerritory() && ! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory ) ) ) { - World w = loc.getWorld(); - double x = loc.getX(); - double y = loc.getY(); - double z = loc.getZ(); + World w = locationHere.getWorld(); + double x = locationHere.getX(); + double y = locationHere.getY(); + double z = locationHere.getZ(); for (Player p : me.getServer().getOnlinePlayers()) { @@ -110,7 +122,7 @@ public class CmdFactionsHome extends FCommand continue; MPlayer fp = MPlayer.get(p); - if (usender.getRelationTo(fp) != Rel.ENEMY) + if (msender.getRelationTo(fp) != Rel.ENEMY) continue; Location l = p.getLocation(); @@ -123,7 +135,7 @@ public class CmdFactionsHome extends FCommand if (dx > max || dy > max || dz > max) continue; - usender.msg("You cannot teleport to your faction home while an enemy is within " + MConf.get().homesTeleportAllowedEnemyDistance + " blocks of you."); + msender.msg("You cannot teleport to %s while an enemy is within %f blocks of you.", homeDesc, MConf.get().homesTeleportAllowedEnemyDistance); return; } } @@ -136,7 +148,7 @@ public class CmdFactionsHome extends FCommand // Apply try { - Mixin.teleport(me, usenderFaction.getHome(), "your faction home", sender); + Mixin.teleport(me, home, homeDesc, sender); } catch (TeleporterException e) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java index 1c81db6b..dc94dae8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -11,7 +11,7 @@ import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; -public class CmdFactionsInvite extends FCommand +public class CmdFactionsInvite extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -43,39 +43,39 @@ public class CmdFactionsInvite extends FCommand MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); if (mplayer == null) return; - Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(mplayer)); + Boolean newInvited = this.arg(1, ARBoolean.get(), !msenderFaction.isInvited(mplayer)); if (newInvited == null) return; // Allready member? - if (mplayer.getFaction() == usenderFaction) + if (mplayer.getFaction() == msenderFaction) { - msg("%s is already a member of %s", mplayer.getName(), usenderFaction.getName()); + msg("%s is already a member of %s", mplayer.getName(), msenderFaction.getName()); msg("You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false)); return; } // FPerm - if ( ! FPerm.INVITE.has(usender, usenderFaction, true)) return; + if ( ! FPerm.INVITE.has(msender, msenderFaction, true)) return; // Event - EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, usenderFaction, newInvited); + EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, newInvited); event.run(); if (event.isCancelled()) return; newInvited = event.isNewInvited(); // Apply - usenderFaction.setInvited(mplayer, newInvited); + msenderFaction.setInvited(mplayer, newInvited); // Inform if (newInvited) { - mplayer.msg("%s invited you to %s", usender.describeTo(mplayer, true), usenderFaction.describeTo(mplayer)); - usenderFaction.msg("%s invited %s to your faction.", usender.describeTo(usenderFaction, true), mplayer.describeTo(usenderFaction)); + mplayer.msg("%s invited you to %s", msender.describeTo(mplayer, true), msenderFaction.describeTo(mplayer)); + msenderFaction.msg("%s invited %s to your faction.", msender.describeTo(msenderFaction, true), mplayer.describeTo(msenderFaction)); } else { - mplayer.msg("%s revoked your invitation to %s.", usender.describeTo(mplayer), usenderFaction.describeTo(mplayer)); - usenderFaction.msg("%s revoked %s's invitation.", usender.describeTo(usenderFaction), mplayer.describeTo(usenderFaction)); + mplayer.msg("%s revoked your invitation to %s.", msender.describeTo(mplayer), msenderFaction.describeTo(mplayer)); + msenderFaction.msg("%s revoked %s's invitation.", msender.describeTo(msenderFaction), mplayer.describeTo(msenderFaction)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java index a6bbc357..e2b18dd4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -12,7 +12,7 @@ import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipC import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsJoin extends FCommand +public class CmdFactionsJoin extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -42,11 +42,11 @@ public class CmdFactionsJoin extends FCommand Faction faction = this.arg(0, ARFaction.get()); if (faction == null) return; - MPlayer mplayer = this.arg(1, ARMPlayer.getAny(), usender); + MPlayer mplayer = this.arg(1, ARMPlayer.getAny(), msender); if (mplayer == null) return; Faction mplayerFaction = mplayer.getFaction(); - boolean samePlayer = mplayer == usender; + boolean samePlayer = mplayer == msender; // Validate if (!samePlayer && ! Perm.JOIN_OTHERS.has(sender, false)) @@ -57,29 +57,29 @@ public class CmdFactionsJoin extends FCommand if (faction == mplayerFaction) { - msg("%s %s already a member of %s.", mplayer.describeTo(usender, true), (samePlayer ? "are" : "is"), faction.getName(usender)); + msg("%s %s already a member of %s.", mplayer.describeTo(msender, true), (samePlayer ? "are" : "is"), faction.getName(msender)); return; } if (MConf.get().factionMemberLimit > 0 && faction.getMPlayers().size() >= MConf.get().factionMemberLimit) { - msg(" ! The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(usender), MConf.get().factionMemberLimit, mplayer.describeTo(usender, false)); + msg(" ! The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(msender), MConf.get().factionMemberLimit, mplayer.describeTo(msender, false)); return; } if (mplayerFaction.isNormal()) { - msg("%s must leave %s current faction first.", mplayer.describeTo(usender, true), (samePlayer ? "your" : "their")); + msg("%s must leave %s current faction first.", mplayer.describeTo(msender, true), (samePlayer ? "your" : "their")); return; } if (!MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0) { - msg("%s cannot join a faction with a negative power level.", mplayer.describeTo(usender, true)); + msg("%s cannot join a faction with a negative power level.", mplayer.describeTo(msender, true)); return; } - if( ! (faction.isOpen() || faction.isInvited(mplayer) || usender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false))) + if( ! (faction.isOpen() || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false))) { msg("This faction requires invitation."); if (samePlayer) @@ -90,17 +90,17 @@ public class CmdFactionsJoin extends FCommand } // Event - EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, usender, faction, MembershipChangeReason.JOIN); + EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.JOIN); membershipChangeEvent.run(); if (membershipChangeEvent.isCancelled()) return; // Inform if (!samePlayer) { - mplayer.msg("%s moved you into the faction %s.", usender.describeTo(mplayer, true), faction.getName(mplayer)); + mplayer.msg("%s moved you into the faction %s.", msender.describeTo(mplayer, true), faction.getName(mplayer)); } faction.msg("%s joined your faction.", mplayer.describeTo(faction, true)); - usender.msg("%s successfully joined %s.", mplayer.describeTo(usender, true), faction.getName(usender)); + msender.msg("%s successfully joined %s.", mplayer.describeTo(msender, true), faction.getName(msender)); // Apply mplayer.resetFactionData(); @@ -117,7 +117,7 @@ public class CmdFactionsJoin extends FCommand } else { - Factions.get().log(Txt.parse("%s moved the player %s into the faction %s.", usender.getName(), mplayer.getName(), faction.getName())); + Factions.get().log(Txt.parse("%s moved the player %s into the faction %s.", msender.getName(), mplayer.getName(), faction.getName())); } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java index c08423fd..ee52a4e8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -14,7 +14,7 @@ import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipC import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.IdUtil; -public class CmdFactionsKick extends FCommand +public class CmdFactionsKick extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -44,14 +44,14 @@ public class CmdFactionsKick extends FCommand if (mplayer == null) return; // Validate - if (usender == mplayer) + if (msender == mplayer) { msg("You cannot kick yourself."); msg("You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsLeave.getUseageTemplate(false)); return; } - if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || usender.isUsingAdminMode())) + if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isUsingAdminMode())) { msg("The leader can not be kicked."); return; @@ -65,7 +65,7 @@ public class CmdFactionsKick extends FCommand // FPerm Faction mplayerFaction = mplayer.getFaction(); - if (!FPerm.KICK.has(usender, mplayerFaction, true)) return; + if (!FPerm.KICK.has(msender, mplayerFaction, true)) return; // Event EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK); @@ -73,16 +73,16 @@ public class CmdFactionsKick extends FCommand if (event.isCancelled()) return; // Inform - mplayerFaction.msg("%s kicked %s from the faction! :O", usender.describeTo(mplayerFaction, true), mplayer.describeTo(mplayerFaction, true)); - mplayer.msg("%s kicked you from %s! :O", usender.describeTo(mplayer, true), mplayerFaction.describeTo(mplayer)); - if (mplayerFaction != usenderFaction) + mplayerFaction.msg("%s kicked %s from the faction! :O", msender.describeTo(mplayerFaction, true), mplayer.describeTo(mplayerFaction, true)); + mplayer.msg("%s kicked you from %s! :O", msender.describeTo(mplayer, true), mplayerFaction.describeTo(mplayer)); + if (mplayerFaction != msenderFaction) { - usender.msg("You kicked %s from the faction %s!", mplayer.describeTo(usender), mplayerFaction.describeTo(usender)); + msender.msg("You kicked %s from the faction %s!", mplayer.describeTo(msender), mplayerFaction.describeTo(msender)); } if (MConf.get().logFactionKick) { - Factions.get().log(usender.getDisplayName(IdUtil.getConsole()) + " kicked " + mplayer.getName() + " from the faction " + mplayerFaction.getName()); + Factions.get().log(msender.getDisplayName(IdUtil.getConsole()) + " kicked " + mplayer.getName() + " from the faction " + mplayerFaction.getName()); } // Apply diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java index 59eedc58..661ae1c4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java @@ -13,7 +13,7 @@ import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsLeader extends FCommand +public class CmdFactionsLeader extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -41,32 +41,32 @@ public class CmdFactionsLeader extends FCommand MPlayer newLeader = this.arg(0, ARMPlayer.getAny()); if (newLeader == null) return; - Faction targetFaction = this.arg(1, ARFaction.get(), usenderFaction); + Faction targetFaction = this.arg(1, ARFaction.get(), msenderFaction); if (targetFaction == null) return; MPlayer targetFactionCurrentLeader = targetFaction.getLeader(); // We now have mplayer and the target faction - if (this.senderIsConsole || usender.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false)) + if (this.senderIsConsole || msender.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false)) { // Do whatever you wish } else { // Follow the standard rules - if (usender.getRole() != Rel.LEADER || targetFaction != usenderFaction) + if (msender.getRole() != Rel.LEADER || targetFaction != msenderFaction) { sender.sendMessage(Txt.parse("You must be leader of the faction to %s.", this.getDesc())); return; } - if (newLeader.getFaction() != usenderFaction) + if (newLeader.getFaction() != msenderFaction) { - msg("%s is not a member in the faction.", newLeader.describeTo(usender, true)); + msg("%s is not a member in the faction.", newLeader.describeTo(msender, true)); return; } - if (newLeader == usender) + if (newLeader == msender) { msg("The target player musn't be yourself."); return; @@ -85,8 +85,8 @@ public class CmdFactionsLeader extends FCommand if (targetFactionCurrentLeader == newLeader) { targetFaction.promoteNewLeader(); - msg("You have demoted %s from the position of faction leader.", newLeader.describeTo(usender, true)); - newLeader.msg("You have been demoted from the position of faction leader by %s.", usender.describeTo(newLeader, true)); + msg("You have demoted %s from the position of faction leader.", newLeader.describeTo(msender, true)); + newLeader.msg("You have been demoted from the position of faction leader by %s.", msender.describeTo(newLeader, true)); return; } @@ -97,12 +97,12 @@ public class CmdFactionsLeader extends FCommand } newLeader.setFaction(targetFaction); newLeader.setRole(Rel.LEADER); - msg("You have promoted %s to the position of faction leader.", newLeader.describeTo(usender, true)); + msg("You have promoted %s to the position of faction leader.", newLeader.describeTo(msender, true)); // Inform all players for (MPlayer mplayer : MPlayerColl.get().getAllOnline()) { - mplayer.msg("%s gave %s the leadership of %s.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(usender, mplayer, true), newLeader.describeTo(mplayer), targetFaction.describeTo(mplayer)); + mplayer.msg("%s gave %s the leadership of %s.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(msender, mplayer, true), newLeader.describeTo(mplayer), targetFaction.describeTo(mplayer)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java index f19c9f8e..ebd4b44c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java @@ -4,7 +4,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsLeave extends FCommand +public class CmdFactionsLeave extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -27,7 +27,7 @@ public class CmdFactionsLeave extends FCommand @Override public void perform() { - usender.leave(); + msender.leave(); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java index 07bb5785..3643e555 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -12,7 +12,7 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsList extends FCommand +public class CmdFactionsList extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -67,7 +67,7 @@ public class CmdFactionsList extends FCommand continue; } lines.add(Txt.parse("%s %d/%d online, %d/%d/%d", - faction.getName(usender), + faction.getName(msender), faction.getMPlayersWhereOnline(true).size(), faction.getMPlayers().size(), faction.getLandCount(), diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java index 187125d6..0e6b5381 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java @@ -7,7 +7,7 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsMap extends FCommand +public class CmdFactionsMap extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -58,7 +58,7 @@ public class CmdFactionsMap extends FCommand public void showMap() { - sendMessage(BoardColl.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw())); + sendMessage(BoardColl.get().getMap(msenderFaction, PS.valueOf(me), me.getLocation().getYaw())); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java index f1b54323..d38cd275 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java @@ -4,7 +4,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsMoney extends FCommand +public class CmdFactionsMoney extends FactionsCommand { // -------------------------------------------- // // FIELDS diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java index 02e39d57..c55c2d7b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java @@ -7,7 +7,7 @@ import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsMoneyBalance extends FCommand +public class CmdFactionsMoneyBalance extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -33,12 +33,12 @@ public class CmdFactionsMoneyBalance extends FCommand @Override public void perform() { - Faction faction = this.arg(0, ARFaction.get(), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; - if (faction != usenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return; + if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return; - Econ.sendBalanceInfo(usender, faction); + Econ.sendBalanceInfo(msender, faction); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java index fde40cf8..f31f43e6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java @@ -14,7 +14,7 @@ import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; -public class CmdFactionsMoneyDeposit extends FCommand +public class CmdFactionsMoneyDeposit extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -44,14 +44,14 @@ public class CmdFactionsMoneyDeposit extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - Faction faction = this.arg(1, ARFaction.get(), usenderFaction); + Faction faction = this.arg(1, ARFaction.get(), msenderFaction); if (faction == null) return; - boolean success = Econ.transferMoney(usender, usender, faction, amount); + boolean success = Econ.transferMoney(msender, msender, faction, amount); if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", usender.getName(), Money.format(amount), faction.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", msender.getName(), Money.format(amount), faction.describeTo(null)))); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java index d44bfee3..38bdc9be 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java @@ -15,7 +15,7 @@ import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; -public class CmdFactionsMoneyTransferFf extends FCommand +public class CmdFactionsMoneyTransferFf extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -52,11 +52,11 @@ public class CmdFactionsMoneyTransferFf extends FCommand Faction to = this.arg(2, ARFaction.get()); if (to == null) return; - boolean success = Econ.transferMoney(usender, from, to, amount); + boolean success = Econ.transferMoney(msender, from, to, amount); if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java index e73d0fab..3ae1d76a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java @@ -17,7 +17,7 @@ import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; -public class CmdFactionsMoneyTransferFp extends FCommand +public class CmdFactionsMoneyTransferFp extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -54,11 +54,11 @@ public class CmdFactionsMoneyTransferFp extends FCommand MPlayer to = this.arg(2, ARMPlayer.getAny()); if (to == null) return; - boolean success = Econ.transferMoney(usender, from, to, amount); + boolean success = Econ.transferMoney(msender, from, to, amount); if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java index 698cfb6c..08686da8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java @@ -17,7 +17,7 @@ import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; -public class CmdFactionsMoneyTransferPf extends FCommand +public class CmdFactionsMoneyTransferPf extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -54,11 +54,11 @@ public class CmdFactionsMoneyTransferPf extends FCommand Faction to = this.arg(2, ARFaction.get()); if (to == null) return; - boolean success = Econ.transferMoney(usender, from, to, amount); + boolean success = Econ.transferMoney(msender, from, to, amount); if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java index 51a418bb..61f2b404 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java @@ -16,7 +16,7 @@ import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; -public class CmdFactionsMoneyWithdraw extends FCommand +public class CmdFactionsMoneyWithdraw extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -46,16 +46,16 @@ public class CmdFactionsMoneyWithdraw extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - Faction from = this.arg(1, ARFaction.get(), usenderFaction); + Faction from = this.arg(1, ARFaction.get(), msenderFaction); if (from == null) return; - MPlayer to = usender; + MPlayer to = msender; - boolean success = Econ.transferMoney(usender, from, to, amount); + boolean success = Econ.transferMoney(msender, from, to, amount); if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", usender.getName(), Money.format(amount), from.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", msender.getName(), Money.format(amount), from.describeTo(null)))); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java index 4f081835..4ad1f34f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java @@ -13,7 +13,7 @@ import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsName extends FCommand +public class CmdFactionsName extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -45,7 +45,7 @@ public class CmdFactionsName extends FCommand // TODO does not first test cover selfcase? - if (FactionColl.get().isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(usenderFaction.getComparisonName())) + if (FactionColl.get().isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(msenderFaction.getComparisonName())) { msg("That name is already taken"); return; @@ -60,26 +60,26 @@ public class CmdFactionsName extends FCommand } // Event - EventFactionsNameChange event = new EventFactionsNameChange(sender, usenderFaction, newName); + EventFactionsNameChange event = new EventFactionsNameChange(sender, msenderFaction, newName); event.run(); if (event.isCancelled()) return; newName = event.getNewName(); // Apply - String oldName = usenderFaction.getName(); - usenderFaction.setName(newName); + String oldName = msenderFaction.getName(); + msenderFaction.setName(newName); // Inform - usenderFaction.msg("%s changed your faction name to %s", usender.describeTo(usenderFaction, true), usenderFaction.getName(usenderFaction)); + msenderFaction.msg("%s changed your faction name to %s", msender.describeTo(msenderFaction, true), msenderFaction.getName(msenderFaction)); if (!MConf.get().broadcastNameChange) return; for (Faction faction : FactionColl.get().getAll()) { - if (faction == usenderFaction) + if (faction == msenderFaction) { continue; } - faction.msg("The player %s changed their faction name from %s to %s.", usender.describeTo(faction, true), usender.getColorTo(faction)+oldName, usenderFaction.getName(faction)); + faction.msg("The player %s changed their faction name from %s to %s.", msender.describeTo(faction, true), msender.getColorTo(faction)+oldName, msenderFaction.getName(faction)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java index 6997de77..157355e0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java @@ -7,7 +7,7 @@ import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsOfficer extends FCommand +public class CmdFactionsOfficer extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -38,19 +38,19 @@ public class CmdFactionsOfficer extends FCommand boolean permAny = Perm.OFFICER_ANY.has(sender, false); Faction targetFaction = you.getFaction(); - if (targetFaction != usenderFaction && !permAny) + if (targetFaction != msenderFaction && !permAny) { - msg("%s is not a member in your faction.", you.describeTo(usender, true)); + msg("%s is not a member in your faction.", you.describeTo(msender, true)); return; } - if (usender != null && usender.getRole() != Rel.LEADER && !permAny) + if (msender != null && msender.getRole() != Rel.LEADER && !permAny) { msg("You are not the faction leader."); return; } - if (you == usender && !permAny) + if (you == msender && !permAny) { msg("The target player musn't be yourself."); return; @@ -67,14 +67,14 @@ public class CmdFactionsOfficer extends FCommand // Revoke you.setRole(Rel.MEMBER); targetFaction.msg("%s is no longer officer in your faction.", you.describeTo(targetFaction, true)); - msg("You have removed officer status from %s.", you.describeTo(usender, true)); + msg("You have removed officer status from %s.", you.describeTo(msender, true)); } else { // Give you.setRole(Rel.OFFICER); targetFaction.msg("%s was promoted to officer in your faction.", you.describeTo(targetFaction, true)); - msg("You have promoted %s to officer.", you.describeTo(usender, true)); + msg("You have promoted %s to officer.", you.describeTo(msender, true)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java index a429839f..909ac0a5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java @@ -8,7 +8,7 @@ import com.massivecraft.factions.event.EventFactionsOpenChange; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsOpen extends FCommand +public class CmdFactionsOpen extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -36,21 +36,21 @@ public class CmdFactionsOpen extends FCommand public void perform() { // Args - Boolean newOpen = this.arg(0, ARBoolean.get(), !usenderFaction.isOpen()); + Boolean newOpen = this.arg(0, ARBoolean.get(), !msenderFaction.isOpen()); if (newOpen == null) return; // Event - EventFactionsOpenChange event = new EventFactionsOpenChange(sender, usenderFaction, newOpen); + EventFactionsOpenChange event = new EventFactionsOpenChange(sender, msenderFaction, newOpen); event.run(); if (event.isCancelled()) return; newOpen = event.isNewOpen(); // Apply - usenderFaction.setOpen(newOpen); + msenderFaction.setOpen(newOpen); // Inform - String descTarget = usenderFaction.isOpen() ? "open" : "closed"; - usenderFaction.msg("%s changed the faction to %s.", usender.describeTo(usenderFaction, true), descTarget); + String descTarget = msenderFaction.isOpen() ? "open" : "closed"; + msenderFaction.msg("%s changed the faction to %s.", msender.describeTo(msenderFaction, true), descTarget); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java index 2ac3ecb7..228f5b15 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java @@ -11,7 +11,7 @@ import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsPerm extends FCommand +public class CmdFactionsPerm extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -40,12 +40,12 @@ public class CmdFactionsPerm extends FCommand @Override public void perform() { - Faction faction = this.arg(0, ARFaction.get(), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; if ( ! this.argIsSet(1)) { - msg(Txt.titleize("Perms for " + faction.describeTo(usender, true))); + msg(Txt.titleize("Perms for " + faction.describeTo(msender, true))); msg(FPerm.getStateHeaders()); for (FPerm perm : FPerm.values()) { @@ -60,14 +60,14 @@ public class CmdFactionsPerm extends FCommand if ( ! this.argIsSet(2)) { - msg(Txt.titleize("Perm for " + faction.describeTo(usender, true))); + msg(Txt.titleize("Perm for " + faction.describeTo(msender, true))); msg(FPerm.getStateHeaders()); msg(perm.getStateInfo(faction.getPermittedRelations(perm), true)); return; } // Do the sender have the right to change perms for this faction? - if ( ! FPerm.PERMS.has(usender, faction, true)) return; + if ( ! FPerm.PERMS.has(msender, faction, true)) return; Rel rel = this.arg(2, ARRel.get()); if (rel == null) return; @@ -91,7 +91,7 @@ public class CmdFactionsPerm extends FCommand faction.setRelationPermitted(FPerm.PERMS, Rel.LEADER, true); } - msg(Txt.titleize("Perm for " + faction.describeTo(usender, true))); + msg(Txt.titleize("Perm for " + faction.describeTo(msender, true))); msg(FPerm.getStateHeaders()); msg(perm.getStateInfo(faction.getPermittedRelations(perm), true)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java index 5be23f6c..33abd840 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java @@ -11,7 +11,7 @@ import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsPlayer extends FCommand +public class CmdFactionsPlayer extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -37,11 +37,11 @@ public class CmdFactionsPlayer extends FCommand public void perform() { // Args - MPlayer mplayer = this.arg(0, ARMPlayer.getAny(), usender); + MPlayer mplayer = this.arg(0, ARMPlayer.getAny(), msender); if (mplayer == null) return; // INFO: Title - msg(Txt.titleize("Player " + mplayer.describeTo(usender))); + msg(Txt.titleize("Player " + mplayer.describeTo(msender))); // INFO: Power (as progress bar) double progressbarQuota = mplayer.getPower() / mplayer.getPowerMax(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java index 90eddd09..7cc11453 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java @@ -9,7 +9,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsPowerBoost extends FCommand +public class CmdFactionsPowerBoost extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -72,7 +72,7 @@ public class CmdFactionsPowerBoost extends FCommand } msg(""+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels."); - Factions.get().log(usender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+"."); + Factions.get().log(msender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+"."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java index 67472540..100615d3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java @@ -6,7 +6,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsPromote extends FCommand +public class CmdFactionsPromote extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -38,13 +38,13 @@ public class CmdFactionsPromote extends FCommand MPlayer you = this.arg(0, ARMPlayer.getAny()); if (you == null) return; - if (you.getFaction() != usenderFaction) + if (you.getFaction() != msenderFaction) { - msg("%s is not a member in your faction.", you.describeTo(usender, true)); + msg("%s is not a member in your faction.", you.describeTo(msender, true)); return; } - if (you == usender) + if (you == msender) { msg("The target player mustn't be yourself."); return; @@ -52,24 +52,24 @@ public class CmdFactionsPromote extends FCommand if (you.getRole() == Rel.RECRUIT) { - if (!usender.getRole().isAtLeast(Rel.OFFICER)) + if (!msender.getRole().isAtLeast(Rel.OFFICER)) { msg("You must be an officer to promote someone to member."); return; } you.setRole(Rel.MEMBER); - usenderFaction.msg("%s was promoted to being a member of your faction.", you.describeTo(usenderFaction, true)); + msenderFaction.msg("%s was promoted to being a member of your faction.", you.describeTo(msenderFaction, true)); } else if (you.getRole() == Rel.MEMBER) { - if (!usender.getRole().isAtLeast(Rel.LEADER)) + if (!msender.getRole().isAtLeast(Rel.LEADER)) { msg("You must be the leader to promote someone to officer."); return; } // Give you.setRole(Rel.OFFICER); - usenderFaction.msg("%s was promoted to being a officer in your faction.", you.describeTo(usenderFaction, true)); + msenderFaction.msg("%s was promoted to being a officer in your faction.", you.describeTo(msenderFaction, true)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index c96713e0..bf07e27a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -11,7 +11,7 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsRelationChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public abstract class CmdFactionsRelationAbstract extends FCommand +public abstract class CmdFactionsRelationAbstract extends FactionsCommand { public Rel targetRelation; @@ -51,40 +51,40 @@ public abstract class CmdFactionsRelationAbstract extends FCommand // Verify - if (otherFaction == usenderFaction) + if (otherFaction == msenderFaction) { msg("Nope! You can't declare a relation to yourself :)"); return; } - if (usenderFaction.getRelationWish(otherFaction) == newRelation) + if (msenderFaction.getRelationWish(otherFaction) == newRelation) { msg("You already have that relation wish set with %s.", otherFaction.getName()); return; } // Event - EventFactionsRelationChange event = new EventFactionsRelationChange(sender, usenderFaction, otherFaction, newRelation); + EventFactionsRelationChange event = new EventFactionsRelationChange(sender, msenderFaction, otherFaction, newRelation); event.run(); if (event.isCancelled()) return; newRelation = event.getNewRelation(); // try to set the new relation - usenderFaction.setRelationWish(otherFaction, newRelation); - Rel currentRelation = usenderFaction.getRelationTo(otherFaction, true); + msenderFaction.setRelationWish(otherFaction, newRelation); + Rel currentRelation = msenderFaction.getRelationTo(otherFaction, true); // if the relation change was successful if (newRelation == currentRelation) { - otherFaction.msg("%s is now %s.", usenderFaction.describeTo(otherFaction, true), newRelation.getDescFactionOne()); - usenderFaction.msg("%s is now %s.", otherFaction.describeTo(usenderFaction, true), newRelation.getDescFactionOne()); + otherFaction.msg("%s is now %s.", msenderFaction.describeTo(otherFaction, true), newRelation.getDescFactionOne()); + msenderFaction.msg("%s is now %s.", otherFaction.describeTo(msenderFaction, true), newRelation.getDescFactionOne()); } // inform the other faction of your request else { - otherFaction.msg("%s wishes to be %s.", usenderFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne()); - otherFaction.msg("Type /"+MConf.get().aliasesF.get(0)+" "+newRelation+" "+usenderFaction.getName()+" to accept."); - usenderFaction.msg("%s were informed that you wish to be %s.", otherFaction.describeTo(usenderFaction, true), newRelation.getColor()+newRelation.getDescFactionOne()); + otherFaction.msg("%s wishes to be %s.", msenderFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne()); + otherFaction.msg("Type /"+MConf.get().aliasesF.get(0)+" "+newRelation+" "+msenderFaction.getName()+" to accept."); + msenderFaction.msg("%s were informed that you wish to be %s.", otherFaction.describeTo(msenderFaction, true), newRelation.getColor()+newRelation.getDescFactionOne()); } // TODO: The ally case should work!! @@ -92,13 +92,13 @@ public abstract class CmdFactionsRelationAbstract extends FCommand if ( newRelation != Rel.TRUCE && otherFaction.getFlag(FFlag.PEACEFUL)) { otherFaction.msg("This will have no effect while your faction is peaceful."); - usenderFaction.msg("This will have no effect while their faction is peaceful."); + msenderFaction.msg("This will have no effect while their faction is peaceful."); } - if ( newRelation != Rel.TRUCE && usenderFaction.getFlag(FFlag.PEACEFUL)) + if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(FFlag.PEACEFUL)) { otherFaction.msg("This will have no effect while their faction is peaceful."); - usenderFaction.msg("This will have no effect while your faction is peaceful."); + msenderFaction.msg("This will have no effect while your faction is peaceful."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java index eae91913..04c42331 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java @@ -12,7 +12,7 @@ import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSFormatHumanSpace; -public class CmdFactionsSeeChunk extends FCommand +public class CmdFactionsSeeChunk extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java index f134baf7..b76f8321 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -5,13 +5,12 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsHomeChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsSethome extends FCommand +public class CmdFactionsSethome extends FactionsCommandHome { // -------------------------------------------- // // CONSTRUCT @@ -26,8 +25,8 @@ public class CmdFactionsSethome extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node)); + this.addRequirements(ReqIsPlayer.get()); } // -------------------------------------------- // @@ -38,25 +37,18 @@ public class CmdFactionsSethome extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; PS newHome = PS.valueOf(me.getLocation()); - // Validate - if ( ! MConf.get().homesEnabled) - { - usender.msg("Sorry, Faction homes are disabled on this server."); - return; - } - // FPerm - if ( ! FPerm.SETHOME.has(usender, faction, true)) return; + if ( ! FPerm.SETHOME.has(msender, faction, true)) return; // Verify - if (!usender.isUsingAdminMode() && !faction.isValidHome(newHome)) + if (!msender.isUsingAdminMode() && !faction.isValidHome(newHome)) { - usender.msg("Sorry, your faction home can only be set inside your own claimed territory."); + msender.msg("Sorry, your faction home can only be set inside your own claimed territory."); return; } @@ -70,11 +62,11 @@ public class CmdFactionsSethome extends FCommand faction.setHome(newHome); // Inform - faction.msg("%s set the home for your faction. You can now use:", usender.describeTo(usenderFaction, true)); + faction.msg("%s set the home for your faction. You can now use:", msender.describeTo(msenderFaction, true)); faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate()); - if (faction != usenderFaction) + if (faction != msenderFaction) { - usender.msg("You have set the home for the "+faction.getName(usender)+" faction."); + msender.msg("You have set the home for " + faction.getName(msender) + "."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java index d4aa0dbe..037cc05c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -12,7 +12,7 @@ import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsTitle extends FCommand +public class CmdFactionsTitle extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -53,7 +53,7 @@ public class CmdFactionsTitle extends FCommand } // Verify - if ( ! canIAdministerYou(usender, you)) return; + if ( ! canIAdministerYou(msender, you)) return; // Event EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle); @@ -65,7 +65,7 @@ public class CmdFactionsTitle extends FCommand you.setTitle(newTitle); // Inform - usenderFaction.msg("%s changed a title: %s", usender.describeTo(usenderFaction, true), you.describeTo(usenderFaction, true)); + msenderFaction.msg("%s changed a title: %s", msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index 6b44c7f6..3e1097ac 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -8,7 +8,7 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsUnclaim extends FCommand +public class CmdFactionsUnclaim extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -37,7 +37,7 @@ public class CmdFactionsUnclaim extends FCommand Faction newFaction = FactionColl.get().getNone(); // Apply - if (usender.tryClaim(newFaction, chunk, true, true)) return; + if (msender.tryClaim(newFaction, chunk, true, true)) return; } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index 3ce2deae..6fbdf2b9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -16,7 +16,7 @@ import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.ps.PS; -public class CmdFactionsUnclaimall extends FCommand +public class CmdFactionsUnclaimall extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT @@ -41,11 +41,11 @@ public class CmdFactionsUnclaimall extends FCommand public void perform() { // Args - Faction faction = usenderFaction; + Faction faction = msenderFaction; Faction newFaction = FactionColl.get().getNone(); // FPerm - if (!FPerm.TERRITORY.has(usender, faction, true)) return; + if (!FPerm.TERRITORY.has(msender, faction, true)) return; // Apply Set chunks = BoardColl.get().getChunks(faction); @@ -68,12 +68,12 @@ public class CmdFactionsUnclaimall extends FCommand } // Inform - usenderFaction.msg("%s unclaimed %d of your %d faction land. You now have %d land claimed.", usender.describeTo(usenderFaction, true), countSuccess, countTotal, countFail); + msenderFaction.msg("%s unclaimed %d of your %d faction land. You now have %d land claimed.", msender.describeTo(msenderFaction, true), countSuccess, countTotal, countFail); // Log if (MConf.get().logLandUnclaims) { - Factions.get().log(usender.getName()+" unclaimed everything for the faction: "+usenderFaction.getName()); + Factions.get().log(msender.getName()+" unclaimed everything for the faction: "+msenderFaction.getName()); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java new file mode 100644 index 00000000..c57cea24 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java @@ -0,0 +1,68 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.FPerm; +import com.massivecraft.factions.Perm; +import com.massivecraft.factions.cmd.arg.ARFaction; +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.event.EventFactionsHomeChange; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; + +public class CmdFactionsUnsethome extends FactionsCommandHome +{ + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public CmdFactionsUnsethome() + { + // Aliases + this.addAliases("unsethome"); + + // Args + this.addOptionalArg("faction", "you"); + + // Requirements + this.addRequirements(ReqHasPerm.get(Perm.UNSETHOME.node)); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void perform() + { + // Args + Faction faction = this.arg(0, ARFaction.get(), msenderFaction); + if (faction == null) return; + + // Other Perm + if (faction != msenderFaction && !Perm.HOME_OTHER.has(sender, true)) return; + + // FPerm + if ( ! FPerm.SETHOME.has(msender, faction, true)) return; + + // NoChange + if ( ! faction.hasHome()) + { + msender.msg("%s does already not have a home.", faction.describeTo(msender)); + return; + } + + // Event + EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, null); + event.run(); + if (event.isCancelled()) return; + + // Apply + faction.setHome(null); + + // Inform + faction.msg("%s unset the home for your faction.", msender.describeTo(msenderFaction, true)); + if (faction != msenderFaction) + { + msender.msg("You have unset the home for " + faction.getName(msender) + "."); + } + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FactionsCommand.java similarity index 83% rename from src/main/java/com/massivecraft/factions/cmd/FCommand.java rename to src/main/java/com/massivecraft/factions/cmd/FactionsCommand.java index 0e4b1410..677c0e79 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FactionsCommand.java @@ -6,15 +6,14 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.util.Txt; -public abstract class FCommand extends MassiveCommand +public abstract class FactionsCommand extends MassiveCommand { // -------------------------------------------- // // FIELDS // -------------------------------------------- // public MPlayer msender; - public MPlayer usender; - public Faction usenderFaction; + public Faction msenderFaction; // -------------------------------------------- // // OVERRIDE @@ -24,12 +23,7 @@ public abstract class FCommand extends MassiveCommand public void fixSenderVars() { this.msender = MPlayer.get(sender); - - this.usender = null; - this.usenderFaction = null; - - this.usender = MPlayer.get(this.sender); - this.usenderFaction = this.usender.getFaction(); + this.msenderFaction = this.msender.getFaction(); } @@ -37,8 +31,7 @@ public abstract class FCommand extends MassiveCommand public void unsetSenderVars() { this.msender = null; - this.usender = null; - this.usenderFaction = null; + this.msenderFaction = null; } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/FactionsCommandHome.java b/src/main/java/com/massivecraft/factions/cmd/FactionsCommandHome.java new file mode 100644 index 00000000..34247597 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/FactionsCommandHome.java @@ -0,0 +1,28 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.cmd.VisibilityMode; + +public class FactionsCommandHome extends FactionsCommand +{ + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public FactionsCommandHome() + { + this.addRequirements(ReqFactionHomesEnabled.get()); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public VisibilityMode getVisibilityMode() + { + return MConf.get().homesEnabled ? super.getVisibilityMode() : VisibilityMode.INVISIBLE; + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java new file mode 100644 index 00000000..820f1885 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java @@ -0,0 +1,37 @@ +package com.massivecraft.factions.cmd.req; + +import org.bukkit.command.CommandSender; + +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.req.ReqAbstract; +import com.massivecraft.massivecore.util.Txt; + +public class ReqFactionHomesEnabled extends ReqAbstract +{ + private static final long serialVersionUID = 1L; + + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ReqFactionHomesEnabled i = new ReqFactionHomesEnabled(); + public static ReqFactionHomesEnabled get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public boolean apply(CommandSender sender, MassiveCommand command) + { + return MConf.get().homesEnabled; + } + + @Override + public String createErrorMessage(CommandSender sender, MassiveCommand command) + { + return Txt.parse("Homes must be enabled on the server to "+(command == null ? "do that" : command.getDesc())+"."); + } + +} diff --git a/src/main/java/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java index ad5aca1b..6c3b5212 100644 --- a/src/main/java/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -29,6 +29,10 @@ public class RelationUtil if (that instanceof Faction) { + if (thatFaction.isNone()) + { + ret = thatFaction.getName(); + } if (me instanceof MPlayer && myFaction == thatFaction) { ret = "your faction"; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 200e72a1..ecb2d553 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -26,6 +26,7 @@ permissions: factions.flag: {description: manage faction flags, default: false} factions.flag.set: {description: set faction flags, default: false} factions.home: {description: teleport to faction home, default: false} + factions.home.other: {description: teleport to another faction home, default: false} factions.invite: {description: set if player is invited, default: false} factions.join: {description: join faction, default: false} factions.join.any: {description: join closed faction, default: false} @@ -59,6 +60,8 @@ permissions: factions.title.color: {description: set player title with color, default: false} factions.unclaim: {description: unclaim land where you stand, default: false} factions.unclaimall: {description: unclaim all land, default: false} + factions.unsethome: {description: unset faction home, default: false} + factions.unsethome.other: {description: unset other faction home, default: false} factions.version: {description: see plugin version, default: false} # -------------------------------------------- # # STAR NOTATION @@ -81,6 +84,7 @@ permissions: factions.flag: true factions.flag.set: true factions.home: true + factions.home.other: true factions.invite: true factions.join: true factions.join.any: true @@ -114,6 +118,8 @@ permissions: factions.title.color: true factions.unclaim: true factions.unclaimall: true + factions.unsethome: true + factions.unsethome.other: true factions.version: true # -------------------------------------------- # # KITS @@ -142,6 +148,8 @@ permissions: children: factions.kit.rank0: true factions.admin: true + factions.home.other: true + factions.unsethome.other: true factions.kit.rank0: default: false children: @@ -187,6 +195,7 @@ permissions: factions.title.color: true factions.unclaim: true factions.unclaimall: true + factions.unsethome: true factions.version: true factions.kit.default: default: true