This commit is contained in:
Olof Larsson 2011-10-09 18:35:39 +02:00
parent 10f535e637
commit a0c8fd8d7d
53 changed files with 974 additions and 860 deletions

View File

@ -7,10 +7,6 @@ import org.bukkit.entity.CreatureType;
public class Conf
{
// track players with admin access who have enabled "admin bypass" mode, and should therefore be able to build anywhere
// not worth saving between server restarts, I think
public static transient Set<String> adminBypassPlayers = Collections.synchronizedSet(new HashSet<String>());
public static List<String> baseCommandAliases = new ArrayList<String>();
public static boolean allowNoSlashCommand = true;

View File

@ -8,7 +8,8 @@ import org.bukkit.entity.Player;
import com.massivecraft.factions.util.MiscUtil;
public class FLocation {
public class FLocation
{
private String worldName = "world";
private int x = 0;
@ -20,31 +21,37 @@ public class FLocation {
// Constructors
//----------------------------------------------//
public FLocation() {
public FLocation()
{
}
public FLocation(String worldName, int x, int z) {
public FLocation(String worldName, int x, int z)
{
this.worldName = worldName;
this.x = x;
this.z = z;
}
public FLocation(Location location) {
public FLocation(Location location)
{
// this(location.getWorld().getName(), (int) Math.floor(location.getX() / cellSize) , (int) Math.floor(location.getZ() / cellSize));
// handy dandy rapid bitshifting instead of division
this(location.getWorld().getName(), location.getBlockX() >> 4, location.getBlockZ() >> 4);
}
public FLocation(Player player) {
public FLocation(Player player)
{
this(player.getLocation());
}
public FLocation(FPlayer fplayer) {
public FLocation(FPlayer fplayer)
{
this(fplayer.getPlayer());
}
public FLocation(Block block) {
public FLocation(Block block)
{
this(block.getLocation());
}
@ -52,31 +59,38 @@ public class FLocation {
// Getters and Setters
//----------------------------------------------//
public String getWorldName() {
public String getWorldName()
{
return worldName;
}
public void setWorldName(String worldName) {
public void setWorldName(String worldName)
{
this.worldName = worldName;
}
public long getX() {
public long getX()
{
return x;
}
public void setX(int x) {
public void setX(int x)
{
this.x = x;
}
public long getZ() {
public long getZ()
{
return z;
}
public void setZ(int z) {
public void setZ(int z)
{
this.z = z;
}
public String getCoordString() {
public String getCoordString()
{
return ""+x+","+z;
}
@ -93,11 +107,14 @@ public class FLocation {
return new FLocation(this.worldName, this.x + dx, this.z + dz);
}
public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
public static HashSet<FLocation> getArea(FLocation from, FLocation to)
{
HashSet<FLocation> ret = new HashSet<FLocation>();
for (long x : MiscUtil.range(from.getX(), to.getX())) {
for (long z : MiscUtil.range(from.getZ(), to.getZ())) {
for (long x : MiscUtil.range(from.getX(), to.getX()))
{
for (long z : MiscUtil.range(from.getZ(), to.getZ()))
{
ret.add(new FLocation(from.getWorldName(), (int)x, (int)z));
}
}
@ -110,7 +127,8 @@ public class FLocation {
//----------------------------------------------//
@Override
public int hashCode() {
public int hashCode()
{
int hash = 3;
hash = 19 * hash + (this.worldName != null ? this.worldName.hashCode() : 0);
hash = 19 * hash + this.x;
@ -119,7 +137,8 @@ public class FLocation {
};
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (obj == this)
return true;
if (!(obj instanceof FLocation))

View File

@ -103,6 +103,10 @@ public class FPlayer extends PlayerEntity
}
}
private transient boolean isAdminBypassing = false;
public boolean isAdminBypassing() { return this.isAdminBypassing; }
public void setIsAdminBypassing(boolean val) { this.isAdminBypassing = val; }
// FIELD: loginPvpDisabled
private transient boolean loginPvpDisabled;
@ -555,7 +559,7 @@ public class FPlayer extends PlayerEntity
}
// if economy is enabled and they're not on the bypass list, make 'em pay
if (makePay && Econ.enabled() && !Conf.adminBypassPlayers.contains(this.getId()))
if (makePay && Econ.enabled() && ! this.isAdminBypassing())
{
double cost = Conf.econCostLeave;
// pay up
@ -625,7 +629,7 @@ public class FPlayer extends PlayerEntity
return false;
}
if (myFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers && !Conf.adminBypassPlayers.contains(this.getId()))
if (myFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers && ! this.isAdminBypassing())
{
sendMessage("Your faction must have at least "+Conf.claimsRequireMinFactionMembers+" members to claim land.");
return false;
@ -667,7 +671,7 @@ public class FPlayer extends PlayerEntity
if
(
Conf.claimsMustBeConnected
&& !Conf.adminBypassPlayers.contains(this.getId())
&& ! this.isAdminBypassing()
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
&& !Board.isConnectedLocation(flocation, myFaction)
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !otherFaction.isNormal())
@ -709,7 +713,7 @@ public class FPlayer extends PlayerEntity
}
// if economy is enabled and they're not on the bypass list, make 'em pay
if (Econ.enabled() && !Conf.adminBypassPlayers.contains(this.getId()))
if (Econ.enabled() && ! this.isAdminBypassing())
{
double cost = Econ.calculateClaimCost(ownedLand, otherFaction.isNormal());
String costString = Econ.moneyString(cost);

View File

@ -46,8 +46,10 @@ public class Faction extends Entity
// FIELD: peacefulExplosionsEnabled
private boolean peacefulExplosionsEnabled;
public void setPeacefulExplosions(boolean disable) { peacefulExplosionsEnabled = disable; } //TODO: Convert to argswitch in command!!
public void setPeacefulExplosions() { setPeacefulExplosions(!peacefulExplosionsEnabled); }
public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; }
public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; }
public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; }
// FIELD: permanent
// "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members
@ -157,7 +159,7 @@ public class Faction extends Entity
public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); }
public boolean noExplosionsInTerritory() { return peaceful && !peacefulExplosionsEnabled; }
// -------------------------------
// Understand the types

View File

@ -197,10 +197,19 @@ public class P extends MPlugin
@Override
public void onDisable()
{
Board.save();
Conf.save();
unhookEssentialsChat();
super.onDisable();
}
@Override
public void postSaveTask()
{
Board.save();
Conf.save();
}
// -------------------------------------------- //
// Integration with other plugins
// -------------------------------------------- //
@ -500,17 +509,4 @@ public class P extends MPlugin
}
*/
// -------------------------------------------- //
// Save all
// -------------------------------------------- //
// TODO: Add a hook to this??
public static void saveAll()
{
// FPlayer.save();
// Faction.save();
Board.save();
Conf.save();
}
}

View File

@ -1,12 +0,0 @@
package com.massivecraft.factions;
public class SaveTask implements Runnable {
//TODO are they removed on disable?
@Override
public void run() {
P.saveAll();
}
}

View File

@ -31,6 +31,7 @@ public abstract class FCommand extends MCommand<P>
}
public FPlayer fme;
public Faction myFaction;
public boolean senderMustBeMember;
public boolean senderMustBeModerator;
public boolean senderMustBeAdmin;
@ -49,10 +50,12 @@ public abstract class FCommand extends MCommand<P>
if (sender instanceof Player)
{
this.fme = FPlayers.i.get((Player)sender);
this.myFaction = this.fme.getFaction();
}
else
{
this.fme = null;
this.myFaction = null;
}
super.execute(sender, args, commandChain);
}
@ -267,7 +270,7 @@ public abstract class FCommand extends MCommand<P>
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost)
{
if ( ! Econ.enabled() || this.fme == null || cost == 0.0 || Conf.adminBypassPlayers.contains(fme.getName()))
if ( ! Econ.enabled() || this.fme == null || cost == 0.0 || fme.isAdminBypassing())
{
return true;
}

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
@ -36,8 +35,6 @@ public class FCommandAdmin extends FCommand
FPlayer fyou = this.argAsBestFPlayerMatch(0);
if (fyou == null) return;
Faction myFaction = fme.getFaction();
if (fyou.getFaction() != myFaction)
{
sendMessageParsed("%s<i> is not a member in your faction.", fyou.getNameAndRelevant(fme));

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
public class FCommandAutoClaim extends FCommand
@ -42,7 +41,6 @@ public class FCommandAutoClaim extends FCommand
return;
}
Faction myFaction = fme.getFaction();
FLocation flocation = new FLocation(fme);
if (Conf.worldsNoClaiming.contains(flocation.getWorldName()))

View File

@ -32,10 +32,10 @@ public class FCommandBalance extends FCommand
return;
}
Faction faction = this.argAsFaction(0, fme.getFaction());
Faction faction = this.argAsFaction(0, myFaction);
// TODO MAKE HIERARCHIAL COMMAND STRUCTURE HERE
if ( faction != fme.getFaction() && ! Permission.VIEW_ANY_FACTION_BALANCE.has(sender))
if ( faction != myFaction && ! Permission.VIEW_ANY_FACTION_BALANCE.has(sender))
{
sendMessageParsed("<b>You do not have sufficient permissions to view the bank balance of other factions.");
return;

View File

@ -1,10 +1,8 @@
package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class FCommandBypass extends FCommand
{
public FCommandBypass()
@ -15,7 +13,7 @@ public class FCommandBypass extends FCommand
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flipp");
this.permission = Permission.ADMIN_BYPASS.node;
this.permission = Permission.COMMAND_BYPASS.node;
senderMustBePlayer = true;
senderMustBeMember = false;
@ -26,16 +24,16 @@ public class FCommandBypass extends FCommand
@Override
public void perform()
{
fme.setIsAdminBypassing(this.argAsBool(0, ! fme.isAdminBypassing()));
// TODO: Move this to a transient field in the model??
if ( ! Conf.adminBypassPlayers.contains(fme.getName()))
if ( fme.isAdminBypassing())
{
Conf.adminBypassPlayers.add(fme.getName());
fme.sendMessageParsed("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
}
else
{
Conf.adminBypassPlayers.remove(fme.getName());
fme.sendMessageParsed("<i>You have disabled admin bypass mode.");
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
}

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.commands;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
public class FCommandDeinvite extends FCommand
@ -36,8 +35,6 @@ public class FCommandDeinvite extends FCommand
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
Faction myFaction = fme.getFaction();
if (you.getFaction() == myFaction)
{
sendMessageParsed("%s<i> is already a member of %s", you.getName(), myFaction.getTag());

View File

@ -33,7 +33,7 @@ public class FCommandDeposit extends FCommand
{
if ( ! Conf.bankEnabled) return;
Faction faction = fme.getFaction();
Faction faction = myFaction;
double amount = this.argAsDouble(0, 0);

View File

@ -39,13 +39,13 @@ public class FCommandDescription extends FCommand
return;
}
fme.getFaction().setDescription(TextUtil.implode(args, " "));
myFaction.setDescription(TextUtil.implode(args, " "));
// Broadcast the description to everyone
for (FPlayer fplayer : FPlayers.i.getOnline())
{
fplayer.sendMessageParsed("The faction "+fplayer.getRelationColor(fme)+fme.getFaction().getTag()+"<i> changed their description to:");
fplayer.sendMessageParsed("<i>"+fme.getFaction().getDescription());
fplayer.sendMessageParsed("The faction "+fplayer.getRelationColor(fme)+myFaction.getTag()+"<i> changed their description to:");
fplayer.sendMessageParsed("<i>"+myFaction.getDescription());
}
}

View File

@ -33,10 +33,10 @@ public class FCommandDisband extends FCommand
public void perform()
{
// The faction, default to your own.. but null if console sender.
Faction faction = this.argAsFaction(0, fme == null ? null : fme.getFaction());
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
if (faction == null) return;
boolean isMyFaction = fme == null ? false : faction == fme.getFaction();
boolean isMyFaction = fme == null ? false : faction == myFaction;
if (isMyFaction)
{

View File

@ -49,8 +49,6 @@ public class FCommandHome extends FCommand
return;
}
Faction myFaction = fme.getFaction();
if ( ! myFaction.hasHome())
{
fme.sendMessage("You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:"));

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
public class FCommandInvite extends FCommand
@ -36,8 +35,6 @@ public class FCommandInvite extends FCommand
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
Faction myFaction = fme.getFaction();
if (you.getFaction() == myFaction)
{
sendMessageParsed("%s<i> is already a member of %s", you.getName(), myFaction.getTag());

View File

@ -40,7 +40,7 @@ public class FCommandJoin extends FCommand
return;
}
if (faction == fme.getFaction())
if (faction == myFaction)
{
sendMessageParsed("<b>You are already a member of %s", faction.getTag(fme));
return;

View File

@ -45,7 +45,6 @@ public class FCommandKick extends FCommand
}
Faction yourFaction = you.getFaction();
Faction myFaction = fme.getFaction();
// players with admin-level "disband" permission can bypass these requirements
if ( ! Permission.COMMAND_KICK_ANY.has(sender))

View File

@ -60,7 +60,7 @@ public class FCommandMap extends FCommand
public void showMap()
{
sendMessage(Board.getMap(fme.getFaction(), new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
sendMessage(Board.getMap(myFaction, new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
}
}

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.commands;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
@ -36,8 +35,6 @@ public class FCommandMod extends FCommand
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
Faction myFaction = fme.getFaction();
if (you.getFaction() != myFaction)
{
sendMessageParsed("%s<b> is not a member in your faction.", you.getNameAndRelevant(fme));

View File

@ -1,58 +1,49 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.struct.Permission;
public class FCommandNoBoom extends FCommand {
public class FCommandNoBoom extends FCommand
{
public FCommandNoBoom()
{
super();
this.aliases.add("noboom");
public FCommandNoBoom() {
aliases.add("noboom");
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flipp");
helpDescription = "Peaceful factions only: toggle explosions";
this.permission = Permission.COMMAND_NO_BOOM.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermPeacefulExplosionToggle(sender);
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
if ( ! assertMinRole(Role.MODERATOR)) {
return;
}
Faction myFaction = fme.getFaction();
if (!myFaction.isPeaceful()) {
fme.sendMessage("This command is only usable by factions which are specially designated as peaceful.");
if ( ! myFaction.isPeaceful())
{
fme.sendMessageParsed("<b>This command is only usable by factions which are specially designated as peaceful.");
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostNoBoom)) {
return;
}
if ( ! payForCommand(Conf.econCostNoBoom)) return;
myFaction.setPeacefulExplosions();
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled()));
String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled";
// Inform
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" has "+enabled+" explosions in your faction's territory.");
myFaction.sendMessageParsed("%s<i> has "+enabled+" explosions in your faction's territory.", fme.getNameAndRelevant(myFaction));
}
}

View File

@ -2,51 +2,52 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
public class FCommandOpen extends FCommand {
public class FCommandOpen extends FCommand
{
public FCommandOpen()
{
super();
this.aliases.add("open");
public FCommandOpen() {
aliases.add("open");
aliases.add("close");
//this.requiredArgs.add("");
this.optionalArgs.put("yes/no", "flipp");
helpDescription = "Switch if invitation is required to join";
this.permission = Permission.COMMAND_OPEN.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
if ( ! assertMinRole(Role.MODERATOR))
{
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOpen))
{
return;
}
if ( ! payForCommand(Conf.econCostOpen)) return;
Faction myFaction = fme.getFaction();
myFaction.setOpen( ! fme.getFaction().getOpen());
myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen()));
String open = myFaction.getOpen() ? "open" : "closed";
// Inform
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open);
for (Faction faction : Faction.getAll()) {
if (faction == fme.getFaction()) {
myFaction.sendMessageParsed("%s<i> changed the faction to ", fme.getNameAndRelevant(myFaction));
for (Faction faction : Factions.i.get())
{
if (faction == myFaction)
{
continue;
}
faction.sendMessage(Conf.colorSystem+"The faction "+myFaction.getTag(faction)+Conf.colorSystem+" is now "+open);
faction.sendMessageParsed("<i>The faction %s<i> is now %s", myFaction.getTag(faction), open);
}
}

View File

@ -4,102 +4,112 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
public class FCommandOwner extends FCommand {
public class FCommandOwner extends FCommand
{
public FCommandOwner() {
aliases.add("owner");
public FCommandOwner()
{
super();
this.aliases.add("owner");
optionalParameters.add("player name");
//this.requiredArgs.add("");
this.optionalArgs.put("player name", "you");
helpDescription = "set ownership of claimed land";
this.permission = Permission.COMMAND_OWNER.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
// TODO: Fix colors!
@Override
public void perform() {
boolean hasBypass = P.hasPermAdminBypass(fme);
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
boolean hasBypass = fme.isAdminBypassing();
if ( ! hasBypass && ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage();
if ( ! Conf.ownedAreasEnabled)
{
fme.sendMessageParsed("<b>Sorry, but owned areas are disabled on this server.");
return;
}
if ( ! Conf.ownedAreasEnabled) {
fme.sendMessage("Sorry, but owned areas are disabled on this server.");
if ( ! hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction)
{
fme.sendMessageParsed("<b>Sorry, but you have reached the server's <h>limit of %d <b>owned areas per faction.", Conf.ownedAreasLimitPerFaction);
return;
}
Faction myFaction = fme.getFaction();
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
fme.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction.");
return;
}
if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) {
if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN))
{
return;
}
FLocation flocation = new FLocation(fme);
if (Board.getIdAt(flocation) != myFaction.getId()) {
if (!hasBypass) {
fme.sendMessage("This land is not claimed by your faction, so you can't set ownership of it.");
Faction factionHere = Board.getFactionAt(flocation);
if (factionHere != myFaction)
{
if ( ! hasBypass)
{
fme.sendMessageParsed("<b>This land is not claimed by your faction, so you can't set ownership of it.");
return;
}
myFaction = Board.getFactionAt(flocation);
if (!myFaction.isNormal()) {
fme.sendMessage("This land is not claimed by a faction. Ownership is not possible.");
if ( ! factionHere.isNormal())
{
fme.sendMessageParsed("<b>This land is not claimed by a faction. Ownership is not possible.");
return;
}
}
FPlayer target;
if (parameters.size() > 0) {
target = findFPlayer(parameters.get(0), false);
} else {
target = fme;
}
if (target == null) {
return;
}
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) return;
String playerName = target.getName();
if (target.getFaction().getId() != myFaction.getId()) {
fme.sendMessage(playerName + " is not a member of this faction.");
if (target.getFaction() != myFaction)
{
fme.sendMessageParsed("%s<i> is not a member of this faction.", playerName);
return;
}
// if no player name was passed, and this claim does already have owners set, clear them
if (parameters.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation))
{
myFaction.clearClaimOwnership(flocation);
fme.sendMessage("You have cleared ownership for this claimed area.");
fme.sendMessageParsed("<i>You have cleared ownership for this claimed area.");
return;
}
if (myFaction.isPlayerInOwnerList(playerName, flocation)) {
if (myFaction.isPlayerInOwnerList(playerName, flocation))
{
myFaction.removePlayerAsOwner(playerName, flocation);
fme.sendMessage("You have removed ownership of this claimed land from "+playerName+".");
fme.sendMessageParsed("<i>You have removed ownership of this claimed land from %s<i>.", playerName);
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOwner)) {
return;
}
if ( ! payForCommand(Conf.econCostOwner)) return;
myFaction.setPlayerAsOwner(playerName, flocation);
fme.sendMessage("You have added "+playerName+" to the owner list for this claimed land.");
fme.sendMessageParsed("<i>You have added %s<i> to the owner list for this claimed land.", playerName);
}
}

View File

@ -1,59 +1,72 @@
package com.massivecraft.factions.commands;
import java.util.Set;
import java.util.Iterator;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class FCommandOwnerList extends FCommand {
public class FCommandOwnerList extends FCommand
{
public FCommandOwnerList() {
aliases.add("ownerlist");
public FCommandOwnerList()
{
super();
this.aliases.add("ownerlist");
helpDescription = "list owner(s) of this claimed land";
//this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_OWNERLIST.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
boolean hasBypass = P.hasPermAdminBypass(fme);
public void perform()
{
boolean hasBypass = fme.isAdminBypassing();
if ( ! hasBypass && ! assertHasFaction()) {
if ( ! hasBypass && ! assertHasFaction())
{
return;
}
if ( ! Conf.ownedAreasEnabled) {
fme.sendMessage("Owned areas are disabled on this server.");
if ( ! Conf.ownedAreasEnabled)
{
fme.sendMessageParsed("<b>Owned areas are disabled on this server.");
return;
}
Faction myFaction = fme.getFaction();
FLocation flocation = new FLocation(fme);
if (Board.getIdAt(flocation) != myFaction.getId()) {
if (!hasBypass) {
fme.sendMessage("This land is not claimed by your faction.");
if (Board.getIdAt(flocation) != myFaction.getId())
{
if (!hasBypass)
{
fme.sendMessageParsed("<b>This land is not claimed by your faction.");
return;
}
myFaction = Board.getFactionAt(flocation);
if (!myFaction.isNormal()) {
fme.sendMessage("This land is not claimed by any faction, thus no owners.");
if (!myFaction.isNormal())
{
fme.sendMessageParsed("<i>This land is not claimed by any faction, thus no owners.");
return;
}
}
String owners = myFaction.getOwnerListString(flocation);
if (owners == null || owners.isEmpty()) {
fme.sendMessage("No owners are set here; everyone in the faction has access.");
if (owners == null || owners.isEmpty())
{
fme.sendMessageParsed("<i>No owners are set here; everyone in the faction has access.");
return;
}
fme.sendMessage("Current owner(s) of this land: "+owners);
fme.sendMessageParsed("<i>Current owner(s) of this land: %s", owners);
}
}

View File

@ -18,7 +18,7 @@ public class FCommandPay extends FCommand
this.requiredArgs.add("faction");
this.requiredArgs.add("amount");
//this.optionalArgs.put("factiontag", "yours");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_PAY.node;

View File

@ -1,59 +1,62 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
public class FCommandPeaceful extends FCommand {
public class FCommandPeaceful extends FCommand
{
public FCommandPeaceful() {
aliases.add("peaceful");
public FCommandPeaceful()
{
super();
this.aliases.add("peaceful");
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_SET_PEACEFUL.node;
senderMustBePlayer = false;
requiredParameters.add("faction tag");
helpDescription = "Designate a faction as peaceful";
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermSetPeaceful(sender);
}
public void perform()
{
Faction faction = this.argAsFaction(0);
if (faction == null) return;
@Override
public void perform() {
if( parameters.size() > 0) {
Faction faction = Faction.findByTag(parameters.get(0));
if (faction == null) {
sendMessage("No faction found with the tag \"" + parameters.get(0) + "\"");
return;
}
String change;
if(faction.isPeaceful()) {
change = "removed peaceful status from";
faction.setPeaceful(false);
} else {
change = "granted peaceful status to";
faction.setPeaceful(true);
}
// Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) {
fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction.");
} else {
fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
}
SpoutFeatures.updateAppearances(faction);
String change;
if (faction.isPeaceful())
{
change = "removed peaceful status from";
faction.setPeaceful(false);
}
else
{
change = "granted peaceful status to";
faction.setPeaceful(true);
}
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == faction)
{
fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+"<i> has "+change+" your faction.");
}
else
{
fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
}
SpoutFeatures.updateAppearances(faction);
}
}

View File

@ -1,57 +1,58 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
public class FCommandPermanent extends FCommand {
public class FCommandPermanent extends FCommand
{
public FCommandPermanent()
{
super();
this.aliases.add("permanent");
public FCommandPermanent() {
aliases.add("permanent");
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_SET_PERMANENT.node;
senderMustBePlayer = false;
requiredParameters.add("faction tag");
helpDescription = "Designate a faction as permanent";
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermSetPermanent(sender);
}
public void perform()
{
Faction faction = this.argAsFaction(0);
if (faction == null) return;
@Override
public void perform() {
if( parameters.size() > 0) {
Faction faction = Faction.findByTag(parameters.get(0));
String change;
if(faction.isPermanent())
{
change = "removed permanent status from";
faction.setPermanent(false);
}
else
{
change = "added permanent status to";
faction.setPermanent(true);
}
if (faction == null) {
sendMessage("No faction found with the tag \"" + parameters.get(0) + "\"");
return;
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == faction)
{
fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+"<i> has "+change+" your faction.");
}
String change;
if(faction.isPermanent()) {
change = "removed permanent status from";
faction.setPermanent(false);
} else {
change = "added permanent status to";
faction.setPermanent(true);
}
// Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) {
fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction.");
} else {
fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
else
{
fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
}
}
}

View File

@ -1,57 +1,41 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
public class FCommandPower extends FCommand
{
public class FCommandPower extends FCommand {
public FCommandPower()
{
super();
this.aliases.add("power");
this.aliases.add("pow");
public FCommandPower() {
aliases.add("power");
aliases.add("pow");
//this.requiredArgs.add("faction tag");
this.optionalArgs.put("player name", "you");
this.permission = Permission.COMMAND_POWER.node;
senderMustBePlayer = false;
optionalParameters.add("player name");
helpDescription = "show player power info";
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return true;
}
public void perform()
{
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) return;
@Override
public void perform() {
FPlayer target;
if (parameters.size() > 0) {
if (!P.hasPermViewAnyPower(fme)) {
fme.sendMessage("You do not have the appropriate permission to view another player's power level.");
return;
}
target = findFPlayer(parameters.get(0), false);
} else if (!(sender instanceof Player)) {
sendMessage("From the console, you must specify a player (f power <player name>).");
return;
} else {
target = fme;
}
if (target == null) {
return;
}
if (target != me && ! Permission.COMMAND_POWER_ANY.has(sender, true)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostPower)) {
return;
}
if ( ! payForCommand(Conf.econCostPower)) return;
sendMessage(target.getNameAndRelevant(fme)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded());
sendMessageParsed("%s<a> - Power / Maxpower: <i>%d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded());
}
}

View File

@ -2,21 +2,11 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.struct.Relation;
public class FCommandRelationAlly extends FRelationCommand {
public FCommandRelationAlly() {
public class FCommandRelationAlly extends FRelationCommand
{
public FCommandRelationAlly()
{
aliases.add("ally");
targetRelation = Relation.ALLY;
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
relation(Relation.ALLY, parameters.get(0));
}
}

View File

@ -2,21 +2,11 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.struct.Relation;
public class FCommandRelationEnemy extends FRelationCommand {
public FCommandRelationEnemy() {
public class FCommandRelationEnemy extends FRelationCommand
{
public FCommandRelationEnemy()
{
aliases.add("enemy");
targetRelation = Relation.ENEMY;
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
relation(Relation.ENEMY, parameters.get(0));
}
}

View File

@ -2,21 +2,11 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.struct.Relation;
public class FCommandRelationNeutral extends FRelationCommand {
public FCommandRelationNeutral() {
public class FCommandRelationNeutral extends FRelationCommand
{
public FCommandRelationNeutral()
{
aliases.add("neutral");
targetRelation = Relation.NEUTRAL;
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
relation(Relation.NEUTRAL, parameters.get(0));
}
}

View File

@ -1,77 +1,77 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class FCommandReload extends FCommand {
public class FCommandReload extends FCommand
{
public FCommandReload() {
aliases.add("reload");
public FCommandReload()
{
super();
this.aliases.add("reload");
//this.requiredArgs.add("");
this.optionalArgs.put("file", "all");
this.permission = Permission.COMMAND_RELOAD.node;
senderMustBePlayer = false;
optionalParameters.add("file");
helpDescription = "reloads all json files, or a specific one";
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermReload(sender);
}
@Override
public void perform() {
P.log("=== RELOAD START ===");
public void perform()
{
long timeInitStart = System.currentTimeMillis();
String fileName = "s";
String file = this.argAsString(0, "all").toLowerCase();
// Was a single file specified?
if (parameters.size() > 0) {
String file = parameters.get(0);
if (file.equalsIgnoreCase("conf") || file.equalsIgnoreCase("conf.json")) {
P.log("RELOADING CONF.JSON");
Conf.load();
fileName = " conf.json";
}
else if (file.equalsIgnoreCase("board") || file.equalsIgnoreCase("board.json")) {
P.log("RELOADING BOARD.JSON");
Board.load();
fileName = " board.json";
}
else if (file.equalsIgnoreCase("factions") || file.equalsIgnoreCase("factions.json")) {
P.log("RELOADING FACTIONS.JSON");
Faction.load();
fileName = " factions.json";
}
else if (file.equalsIgnoreCase("players") || file.equalsIgnoreCase("players.json")) {
P.log("RELOADING PLAYERS.JSON");
FPlayer.load();
fileName = " players.json";
}
else {
P.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
sendMessage("Invalid file specified. Valid files: conf, board, factions, players.");
return;
}
}
else {
P.log("RELOADING ALL FILES");
String fileName;
if (file.startsWith("c"))
{
Conf.load();
FPlayer.load();
Faction.load();
fileName = "conf.json";
}
else if (file.startsWith("b"))
{
Board.load();
fileName = "board.json";
}
else if (file.startsWith("f"))
{
Factions.i.loadFromDisc();
fileName = "factions.json";
}
else if (file.startsWith("p"))
{
FPlayers.i.loadFromDisc();
fileName = "players.json";
}
else if (file.startsWith("a"))
{
fileName = "all";
Conf.load();
FPlayers.i.loadFromDisc();
Factions.i.loadFromDisc();
Board.load();
}
else
{
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
sendMessageParsed("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
return;
}
long timeReload = (System.currentTimeMillis()-timeInitStart);
P.log("=== RELOAD DONE (Took "+timeReload+"ms) ===");
sendMessage("Factions file" + fileName + " reloaded from disk, took " + timeReload + "ms");
sendMessageParsed("reloaded %s from disk, took %dms", fileName, timeReload);
}
}

View File

@ -1,32 +1,36 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
public class FCommandSafeclaim extends FCommand {
public class FCommandSafeclaim extends FCommand
{
public FCommandSafeclaim() {
aliases.add("safeclaim");
aliases.add("safe");
public FCommandSafeclaim()
{
this.aliases.add("safeclaim");
this.aliases.add("safe");
optionalParameters.add("radius");
//this.requiredArgs.add("");
this.optionalArgs.put("radius", "0");
helpDescription = "Claim land for the safezone";
this.permission = Permission.MANAGE_SAFE_ZONE.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.setHelpShort("Claim land for the safezone");
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermManageSafeZone(sender);
}
@Override
public void perform() {
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
@ -34,31 +38,18 @@ public class FCommandSafeclaim extends FCommand {
// The current location of the player
FLocation playerFlocation = new FLocation(fme);
// Was a radius set?
if (parameters.size() > 0) {
int radius;
try {
radius = Integer.parseInt(parameters.get(0));
}
catch(NumberFormatException ex) {
sendMessage("Usage: " + getUseageTemplate(false));
sendMessage("The radius value must be an integer.");
return;
}
int radius = this.argAsInt(0, 0);
if (radius < 0) radius = 0;
FLocation from = playerFlocation.getRelative(radius, radius);
FLocation to = playerFlocation.getRelative(-radius, -radius);
FLocation from = playerFlocation.getRelative(radius, radius);
FLocation to = playerFlocation.getRelative(-radius, -radius);
for (FLocation locToClaim : FLocation.getArea(from, to)) {
Board.setFactionAt(Faction.getSafeZone(), locToClaim);
}
sendMessage("You claimed "+(1+radius*2)*(1+radius*2)+" chunks for the safe zone.");
} else {
Board.setFactionAt(Faction.getSafeZone(), playerFlocation);
sendMessage("This land is now a safe zone.");
for (FLocation locToClaim : FLocation.getArea(from, to))
{
Board.setFactionAt(Factions.i.getSafeZone(), locToClaim);
}
sendMessageParsed("<i>You claimed <h>%d chunks<i> for the <a>safe zone.", (1+radius*2)*(1+radius*2));
}
}

View File

@ -1,35 +1,41 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
public class FCommandSafeunclaimall extends FCommand {
public class FCommandSafeunclaimall extends FCommand
{
public FCommandSafeunclaimall() {
aliases.add("safeunclaimall");
aliases.add("safedeclaimall");
public FCommandSafeunclaimall()
{
this.aliases.add("safeunclaimall");
this.aliases.add("safedeclaimall");
helpDescription = "Unclaim all safezone land";
//this.requiredArgs.add("");
this.optionalArgs.put("radius", "0");
this.permission = Permission.MANAGE_SAFE_ZONE.node;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.setHelpShort("Unclaim all safezone land");
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermManageSafeZone(sender);
}
@Override
public void perform() {
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
Board.unclaimAll(Faction.getSafeZone().getId());
sendMessage("You unclaimed ALL safe zone land.");
Board.unclaimAll(Factions.i.getSafeZone().getId());
sendMessageParsed("<i>You unclaimed ALL safe zone land.");
}
}

View File

@ -1,30 +1,39 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.P;
public class FCommandSaveAll extends FCommand
{
public class FCommandSaveAll extends FCommand {
public FCommandSaveAll()
{
super();
this.aliases.add("saveall");
this.aliases.add("save");
public FCommandSaveAll() {
aliases.add("saveall");
aliases.add("save");
//this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_SAVE.node;
senderMustBePlayer = false;
helpDescription = "save factions to disk";
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermSaveAll(sender);
}
@Override
public void perform() {
P.saveAll();
sendMessage("Factions saved to disk!");
public void perform()
{
FPlayers.i.saveToDisc();
Factions.i.saveToDisc();
Board.save();
Conf.save();
sendMessageParsed("<i>Factions saved to disk!");
}
}

View File

@ -1,72 +1,81 @@
package com.massivecraft.factions.commands;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
public class FCommandSethome extends FCommand {
public class FCommandSethome extends FCommand
{
public FCommandSethome()
{
this.aliases.add("sethome");
public FCommandSethome() {
aliases.add("sethome");
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "mine");
optionalParameters.add("faction tag");
this.permission = Permission.COMMAND_SETHOME.node;
helpDescription = "Set the faction home";
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
if ( ! assertMinRole(Role.MODERATOR)) {
if ( ! Conf.homesEnabled)
{
fme.sendMessageParsed("<b>Sorry, Faction homes are disabled on this server.");
return;
}
if ( ! Conf.homesEnabled) {
fme.sendMessage("Sorry, Faction homes are disabled on this server.");
return;
Faction faction = this.argAsFaction(0, myFaction);
if (faction == null) return;
// Can the player set the home for this faction?
if (faction == myFaction)
{
if ( ! Permission.COMMAND_SETHOME_ANY.has(sender) && ! assertMinRole(Role.MODERATOR)) return;
}
else
{
if (Permission.COMMAND_SETHOME_ANY.has(sender, true)) return;
}
Faction myFaction = fme.getFaction();
if (parameters.size() > 0) {
if (!P.hasPermAdminBypass(fme)) {
fme.sendMessage("You cannot set the home of another faction without adminBypass permission.");
return;
}
myFaction = findFaction(parameters.get(0), true);
if (myFaction == null) {
fme.sendMessage("No such faction seems to exist.");
return;
}
}
if (Conf.homesMustBeInClaimedTerritory && !fme.isInOwnTerritory() && !P.hasPermAdminBypass(fme)) {
fme.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
// Can the player set the faction home HERE?
if
(
! Permission.COMMAND_BYPASS.has(me)
&&
Conf.homesMustBeInClaimedTerritory
&&
Board.getFactionAt(new FLocation(me)) != faction
)
{
fme.sendMessageParsed("<b>Sorry, your faction home can only be set inside your own claimed territory.");
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostSethome)) {
return;
}
if ( ! payForCommand(Conf.econCostSethome)) return;
myFaction.setHome(fme.getLocation());
faction.setHome(me.getLocation());
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
myFaction.sendMessage(new FCommandHome().getUseageTemplate());
if (myFaction != fme.getFaction()) {
fme.sendMessage("You have set the home for the "+myFaction.getTag(fme)+Conf.colorSystem+" faction.");
faction.sendMessage(fme.getNameAndRelevant(myFaction)+"<i> set the home for your faction. You can now use:");
faction.sendMessage(new FCommandHome().getUseageTemplate());
if (faction != myFaction)
{
fme.sendMessageParsed("<b>You have set the home for the "+faction.getTag(fme)+"<i> faction.");
}
}

View File

@ -2,114 +2,112 @@ package com.massivecraft.factions.commands;
import java.util.Collection;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.TextUtil;
public class FCommandShow extends FCommand
{
public class FCommandShow extends FCommand {
public FCommandShow()
{
this.aliases.add("show");
this.aliases.add("who");
public FCommandShow() {
aliases.add("show");
aliases.add("who");
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours");
senderMustBePlayer = false;
this.permission = Permission.COMMAND_SHOW.node;
optionalParameters.add("faction tag");
helpDescription = "Show faction information";
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return true;
}
@Override
public void perform() {
Faction faction;
if (parameters.size() > 0) {
faction = findFaction(parameters.get(0), true);
} else if (!(sender instanceof Player)) {
sendMessage("From the command line, you must specify a faction tag (f who <faction tag>).");
return;
} else {
faction = fme.getFaction();
}
if (faction == null) {
return;
}
public void perform()
{
Faction faction = this.argAsFaction(0, myFaction);
if (faction == null) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostShow)) {
return;
}
if ( ! payForCommand(Conf.econCostShow)) return;
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
sendMessage(TextUtil.titleize(faction.getTag(fme)));
sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription());
if ( ! faction.isNormal()) {
sendMessageParsed(p.txt.titleize(faction.getTag(fme)));
sendMessageParsed("<a>Description: <i>%s", faction.getDescription());
if ( ! faction.isNormal())
{
return;
}
String peaceStatus = "";
if (faction.isPeaceful()) {
if (faction.isPeaceful())
{
peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful";
}
sendMessage(Conf.colorChrome+"Joining: "+Conf.colorSystem+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
sendMessage(Conf.colorChrome+"Land / Power / Maxpower: "+Conf.colorSystem+ faction.getLandRounded()+" / "+faction.getPowerRounded()+" / "+faction.getPowerMaxRounded());
sendMessageParsed("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
sendMessageParsed("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
if (faction.isPermanent()) {
sendMessage(Conf.colorChrome+"This faction is permanent, remaining even with no members.");
if (faction.isPermanent())
{
sendMessageParsed("<a>This faction is permanent, remaining even with no members.");
}
// show the land value
if (Econ.enabled()) {
if (Econ.enabled())
{
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
double refund = value * Conf.econClaimRefundMultiplier;
if (value > 0) {
if (value > 0)
{
String stringValue = Econ.moneyString(value);
String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : "";
sendMessage(Conf.colorChrome+"Total land value: " + Conf.colorSystem + stringValue + stringRefund);
sendMessageParsed("<a>Total land value: <i>" + stringValue + stringRefund);
}
//Show bank contents
if(Conf.bankEnabled) {
sendMessage(Conf.colorChrome+"Bank contains: " + Conf.colorSystem + Econ.moneyString(faction.getMoney()));
sendMessageParsed("<a>Bank contains: <i>"+Econ.moneyString(faction.getMoney()));
}
}
String listpart;
// List relation
String allyList = Conf.colorChrome+"Allies: ";
String enemyList = Conf.colorChrome+"Enemies: ";
for (Faction otherFaction : Faction.getAll()) {
if (otherFaction == faction) {
String allyList = p.txt.parse("<a>Allies: ");
String enemyList = p.txt.parse("<a>Enemies: ");
for (Faction otherFaction : Factions.i.get())
{
if (otherFaction == faction)
{
continue;
}
listpart = otherFaction.getTag(fme)+Conf.colorSystem+", ";
if (otherFaction.getRelation(faction).isAlly()) {
listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
if (otherFaction.getRelation(faction).isAlly())
{
allyList += listpart;
} else if (otherFaction.getRelation(faction).isEnemy()) {
}
else if (otherFaction.getRelation(faction).isEnemy())
{
enemyList += listpart;
}
}
if (allyList.endsWith(", ")) {
if (allyList.endsWith(", "))
{
allyList = allyList.substring(0, allyList.length()-2);
}
if (enemyList.endsWith(", ")) {
if (enemyList.endsWith(", "))
{
enemyList = enemyList.substring(0, enemyList.length()-2);
}
@ -117,26 +115,33 @@ public class FCommandShow extends FCommand {
sendMessage(enemyList);
// List the members...
String onlineList = Conf.colorChrome+"Members online: ";
String offlineList = Conf.colorChrome+"Members offline: ";
for (FPlayer follower : admins) {
listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", ";
if (follower.isOnline()) {
String onlineList = p.txt.parse("<a>")+"Members online: ";
String offlineList = p.txt.parse("<a>")+"Members offline: ";
for (FPlayer follower : admins)
{
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if (follower.isOnline())
{
onlineList += listpart;
} else {
}
else
{
offlineList += listpart;
}
}
for (FPlayer follower : mods) {
listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", ";
if (follower.isOnline()) {
for (FPlayer follower : mods)
{
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if
(follower.isOnline())
{
onlineList += listpart;
} else {
offlineList += listpart;
}
}
for (FPlayer follower : normals) {
listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", ";
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if (follower.isOnline()) {
onlineList += listpart;
} else {

View File

@ -4,71 +4,74 @@ import java.util.ArrayList;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.TextUtil;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.MiscUtil;
public class FCommandTag extends FCommand
{
public class FCommandTag extends FCommand {
public FCommandTag()
{
this.aliases.add("tag");
public FCommandTag() {
aliases.add("tag");
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
requiredParameters.add("faction tag");
this.permission = Permission.COMMAND_TAG.node;
helpDescription = "Change the faction tag";
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
if ( ! assertMinRole(Role.MODERATOR)) {
return;
}
String tag = parameters.get(0);
String tag = this.argAsString(0);
// TODO does not first test cover selfcase?
if (Faction.isTagTaken(tag) && ! TextUtil.getComparisonString(tag).equals(fme.getFaction().getComparisonTag())) {
sendMessage("That tag is already taken");
if (Factions.i.isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag()))
{
sendMessageParsed("<b>That tag is already taken");
return;
}
ArrayList<String> errors = new ArrayList<String>();
errors.addAll(Faction.validateTag(tag));
if (errors.size() > 0) {
errors.addAll(Factions.validateTag(tag));
if (errors.size() > 0)
{
sendMessage(errors);
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostTag)) {
return;
}
Faction myFaction = fme.getFaction();
if ( ! payForCommand(Conf.econCostTag)) return;
String oldtag = myFaction.getTag();
myFaction.setTag(tag);
// Inform
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed your faction tag to "+Conf.colorMember+myFaction.getTag());
for (Faction faction : Faction.getAll()) {
if (faction == fme.getFaction()) {
myFaction.sendMessageParsed("%s<i> changed your faction tag to %s", fme.getNameAndRelevant(myFaction), myFaction.getTag(myFaction));
for (Faction faction : Factions.i.get())
{
if (faction == myFaction)
{
continue;
}
faction.sendMessage(Conf.colorSystem+"The faction "+fme.getRelationColor(faction)+oldtag+Conf.colorSystem+" changed their name to "+myFaction.getTag(faction));
faction.sendMessageParsed("<i>The faction %s<i> changed their name to %s.", fme.getRelationColor(faction)+oldtag, myFaction.getTag(faction));
}
if (Conf.spoutFactionTagsOverNames) {
if (Conf.spoutFactionTagsOverNames)
{
SpoutFeatures.updateAppearances(myFaction);
}
}

View File

@ -2,59 +2,55 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.util.TextUtil;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TextUtil;
public class FCommandTitle extends FCommand {
public class FCommandTitle extends FCommand
{
public FCommandTitle()
{
this.aliases.add("title");
public FCommandTitle() {
aliases.add("title");
this.requiredArgs.add("player name");
this.optionalArgs.put("title", "");
requiredParameters.add("player name");
this.permission = Permission.COMMAND_TITLE.node;
optionalParameters.add("title");
helpDescription = "Set or remove a players title";
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
String playerName = parameters.get(0);
parameters.remove(0);
String title = TextUtil.implode(parameters);
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
FPlayer you = findFPlayer(playerName, false);
if (you == null) {
return;
}
args.remove(0);
String title = TextUtil.implode(args, " ");
if ( ! canIAdministerYou(fme, you)) {
return;
}
if ( ! canIAdministerYou(fme, you)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostTitle)) {
return;
}
if ( ! payForCommand(Conf.econCostTitle)) return;
you.setTitle(title);
// Inform
Faction myFaction = fme.getFaction();
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction));
myFaction.sendMessageParsed("%s<i> changed a title: %s", fme.getNameAndRelevant(myFaction), you.getNameAndRelevant(myFaction));
if (Conf.spoutFactionTitlesOverNames) {
SpoutFeatures.updateAppearances(fme);
if (Conf.spoutFactionTitlesOverNames)
{
SpoutFeatures.updateAppearances(me);
}
}

View File

@ -5,22 +5,32 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
public class FCommandUnclaim extends FCommand {
public class FCommandUnclaim extends FCommand
{
public FCommandUnclaim()
{
this.aliases.add("unclaim");
this.aliases.add("declaim");
public FCommandUnclaim() {
aliases.add("unclaim");
aliases.add("declaim");
//this.requiredArgs.add("");
//this.optionalArgs.put("", "");
helpDescription = "Unclaim the land where you are standing";
this.permission = Permission.COMMAND_UNCLAIM.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if( isLocked() ) {
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
@ -28,88 +38,110 @@ public class FCommandUnclaim extends FCommand {
FLocation flocation = new FLocation(fme);
Faction otherFaction = Board.getFactionAt(flocation);
if (otherFaction.isSafeZone()) {
if (P.hasPermManageSafeZone(sender)) {
if (otherFaction.isSafeZone())
{
if (Permission.MANAGE_SAFE_ZONE.has(sender))
{
Board.removeAt(flocation);
sendMessage("Safe zone was unclaimed.");
} else {
sendMessage("This is a safe zone. You lack permissions to unclaim.");
sendMessageParsed("<i>Safe zone was unclaimed.");
}
else
{
sendMessageParsed("<b>This is a safe zone. You lack permissions to unclaim.");
}
return;
}
else if (otherFaction.isWarZone()) {
if (P.hasPermManageWarZone(sender)) {
else if (otherFaction.isWarZone())
{
if (Permission.MANAGE_WAR_ZONE.has(sender))
{
Board.removeAt(flocation);
sendMessage("War zone was unclaimed.");
} else {
sendMessage("This is a war zone. You lack permissions to unclaim.");
sendMessageParsed("<i>War zone was unclaimed.");
}
else
{
sendMessageParsed("<b>This is a war zone. You lack permissions to unclaim.");
}
return;
}
if (Conf.adminBypassPlayers.contains(fme.getName())) {
if (fme.isAdminBypassing())
{
Board.removeAt(flocation);
otherFaction.sendMessage(fme.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land.");
sendMessage("You unclaimed this land.");
otherFaction.sendMessageParsed("%s<i> unclaimed some of your land.", fme.getNameAndRelevant(otherFaction));
sendMessageParsed("<i>You unclaimed this land.");
return;
}
if ( ! assertHasFaction()) {
if ( ! assertHasFaction())
{
return;
}
if ( ! assertMinRole(Role.MODERATOR)) {
if ( ! assertMinRole(Role.MODERATOR))
{
return;
}
Faction myFaction = fme.getFaction();
if ( myFaction != otherFaction) {
sendMessage("You don't own this land.");
if ( myFaction != otherFaction)
{
sendMessageParsed("<b>You don't own this land.");
return;
}
String moneyBack = "";
if (Econ.enabled()) {
String moneyBack = "<i>";
if (Econ.enabled())
{
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
// a real refund
if (refund > 0.0) {
if(Conf.bankFactionPaysLandCosts) {
Faction faction = fme.getFaction();
if (refund > 0.0)
{
if(Conf.bankFactionPaysLandCosts)
{
Faction faction = myFaction;
faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+".";
} else {
moneyBack = " "+faction.getTag()+"<i> received a refund of <h>"+Econ.moneyString(refund)+"<i>.";
}
else
{
Econ.addMoney(fme.getName(), refund);
moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
moneyBack = " They received a refund of <h>"+Econ.moneyString(refund)+"<i>.";
}
}
// wait, you're charging people to unclaim land? outrageous
else if (refund < 0.0) {
if(Conf.bankFactionPaysLandCosts) {
Faction faction = fme.getFaction();
if(!faction.removeMoney(-refund)) {
sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford.");
else if (refund < 0.0)
{
if(Conf.bankFactionPaysLandCosts)
{
Faction faction = myFaction;
if(!faction.removeMoney(-refund))
{
sendMessageParsed("<b>Unclaiming this land will cost <h>%s<b> which your faction can't currently afford.", Econ.moneyString(-refund));
return;
}
moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+".";
} else {
if (!Econ.deductMoney(fme.getName(), -refund)) {
sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
moneyBack = " It cost "+faction.getTag()+" <h>"+Econ.moneyString(refund)+"<i>.";
}
else
{
if (!Econ.deductMoney(fme.getName(), -refund))
{
sendMessageParsed("<b>Unclaiming this land will cost <h>%s<b> which you can't currently afford.", Econ.moneyString(-refund));
return;
}
moneyBack = " It cost them "+Econ.moneyString(refund)+".";
moneyBack = " It cost them <h>"+Econ.moneyString(refund)+"<i>.";
}
}
// no refund
else {
else
{
moneyBack = "";
}
}
Board.removeAt(flocation);
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack);
myFaction.sendMessageParsed("%s<i> unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction));
}
}

View File

@ -30,15 +30,13 @@ public class FCommandUnclaimall extends FCommand {
return;
}
Faction myFaction = fme.getFaction();
String moneyBack = "";
if (Econ.enabled()) {
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
// a real refund
if (refund > 0.0) {
if(Conf.bankFactionPaysLandCosts) {
Faction faction = fme.getFaction();
Faction faction = myFaction;
faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+".";
} else {
@ -49,7 +47,7 @@ public class FCommandUnclaimall extends FCommand {
// wait, you're charging people to unclaim land? outrageous
else if (refund < 0.0) {
if(Conf.bankFactionPaysLandCosts) {
Faction faction = fme.getFaction();
Faction faction = myFaction;
if(!faction.removeMoney(-refund)) {
sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford.");
return;

View File

@ -1,28 +1,29 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class FCommandVersion extends FCommand {
public class FCommandVersion extends FCommand
{
public FCommandVersion()
{
this.aliases.add("version");
public FCommandVersion() {
aliases.add("version");
//this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_VERSION.node;
senderMustBePlayer = false;
helpDescription = "Which version are you using?";
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public boolean hasPermission(CommandSender sender) {
return true;
public void perform()
{
sendMessageParsed("<i>You are running "+P.p.getDescription().getFullName());
}
@Override
public void perform() {
sendMessage("You are running "+P.p.getDescription().getFullName());
}
}

View File

@ -39,7 +39,7 @@ public class FCommandWithdraw extends FCommand
return;
}
Faction faction = fme.getFaction();
Faction faction = myFaction;
double amount = this.argAsDouble(0, 0d);

View File

@ -4,76 +4,82 @@ import org.bukkit.ChatColor;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
public abstract class FRelationCommand extends FCommand
{
public Relation targetRelation;
public class FRelationCommand extends FCommand {
public FRelationCommand()
{
super();
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("player name", "you");
public FRelationCommand() {
requiredParameters.add("faction tag");
this.permission = Permission.COMMAND_RELATION.node;
helpDescription = "Set relation wish to another faction";
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
public void relation(Relation whishedRelation, String otherFactionName) {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
@Override
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
if ( ! assertMinRole(Role.MODERATOR)) {
Faction them = this.argAsFaction(0);
if ( ! them.isNormal())
{
sendMessageParsed("<b>Nope! You can't.");
return;
}
Faction myFaction = fme.getFaction();
Faction otherFaction = findFaction(otherFactionName, false);
if (otherFaction == null) {
return;
}
if (!otherFaction.isNormal()) {
sendMessage("Nope! You can't :) You can only ally with player factions.");
return;
}
if (otherFaction == myFaction) {
sendMessage("Nope! You can't declare a relation to yourself :)");
if (them == myFaction)
{
sendMessageParsed("<b>Nope! You can't declare a relation to yourself :)");
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
double cost = whishedRelation.isAlly() ? Conf.econCostAlly : (whishedRelation.isEnemy() ? Conf.econCostEnemy : Conf.econCostNeutral);
if (!payForCommand(cost)) {
return;
}
if ( ! payForCommand(targetRelation.getRelationCost())) return;
myFaction.setRelationWish(otherFaction, whishedRelation);
Relation currentRelation = myFaction.getRelation(otherFaction, true);
myFaction.setRelationWish(them, targetRelation);
Relation currentRelation = myFaction.getRelation(them, true);
ChatColor currentRelationColor = currentRelation.getColor();
if (whishedRelation.value == currentRelation.value) {
otherFaction.sendMessage(Conf.colorSystem+"Your faction is now "+currentRelationColor+whishedRelation.toString()+Conf.colorSystem+" to "+currentRelationColor+myFaction.getTag());
myFaction.sendMessage(Conf.colorSystem+"Your faction is now "+currentRelationColor+whishedRelation.toString()+Conf.colorSystem+" to "+currentRelationColor+otherFaction.getTag());
} else {
otherFaction.sendMessage(currentRelationColor+myFaction.getTag()+Conf.colorSystem+ " wishes to be your "+whishedRelation.getColor()+whishedRelation.toString());
otherFaction.sendMessage(Conf.colorSystem+"Type "+Conf.colorCommand+P.p.getBaseCommand()+" "+whishedRelation+" "+myFaction.getTag()+Conf.colorSystem+" to accept.");
myFaction.sendMessage(currentRelationColor+otherFaction.getTag()+Conf.colorSystem+ " were informed that you wish to be "+whishedRelation.getColor()+whishedRelation);
if (targetRelation.value == currentRelation.value)
{
them.sendMessageParsed("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+myFaction.getTag());
myFaction.sendMessageParsed("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+them.getTag());
}
if (!whishedRelation.isNeutral() && otherFaction.isPeaceful()) {
otherFaction.sendMessage(Conf.colorSystem+"This will have no effect while your faction is peaceful.");
myFaction.sendMessage(Conf.colorSystem+"This will have no effect while their faction is peaceful.");
}
if (!whishedRelation.isNeutral() && myFaction.isPeaceful()) {
otherFaction.sendMessage(Conf.colorSystem+"This will have no effect while their faction is peaceful.");
myFaction.sendMessage(Conf.colorSystem+"This will have no effect while your faction is peaceful.");
else
{
them.sendMessageParsed(currentRelationColor+myFaction.getTag()+"<i> wishes to be your "+targetRelation.getColor()+targetRelation.toString());
them.sendMessageParsed("<i>Type <c>/"+Conf.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+"<i> to accept.");
myFaction.sendMessageParsed(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
}
SpoutFeatures.updateAppearances(myFaction, otherFaction);
if ( ! targetRelation.isNeutral() && them.isPeaceful())
{
them.sendMessageParsed("<i>This will have no effect while your faction is peaceful.");
myFaction.sendMessageParsed("<i>This will have no effect while their faction is peaceful.");
}
if ( ! targetRelation.isNeutral() && myFaction.isPeaceful())
{
them.sendMessageParsed("<i>This will have no effect while their faction is peaceful.");
myFaction.sendMessageParsed("<i>This will have no effect while your faction is peaceful.");
}
SpoutFeatures.updateAppearances(myFaction, them);
}
}

View File

@ -174,19 +174,20 @@ public class FactionsBlockListener extends BlockListener
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck)
{
FPlayer me = FPlayers.i.get(player);
if (Conf.adminBypassPlayers.contains(player.getName()))
if (me.isAdminBypassing())
{
return true;
}
FLocation loc = new FLocation(location);
Faction otherFaction = Board.getFactionAt(loc);
FPlayer me = FPlayers.i.get(player);
if (otherFaction.isNone())
{
if (!Conf.wildernessDenyBuild || Permission.ADMIN_BYPASS.has(player) || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
{
return true; // This is not faction territory. Use whatever you like here.
}

View File

@ -439,18 +439,17 @@ public class FactionsEntityListener extends EntityListener
public boolean playerCanDoPaintings(Player player, FLocation loc, String action)
{
if (Conf.adminBypassPlayers.contains(player.getName()))
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing())
{
return true;
}
Faction otherFaction = Board.getFactionAt(loc);
FPlayer me = FPlayers.i.get(player);
if (otherFaction.isNone())
{
if (!Conf.wildernessDenyBuild || Permission.ADMIN_BYPASS.has(player) || Conf.worldsNoWildernessProtection.contains(player.getWorld().getName()))
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(player.getWorld().getName()))
{
return true; // This is not faction territory. Use whatever you like here.
}

View File

@ -331,8 +331,8 @@ public class FactionsPlayerListener extends PlayerListener
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck)
{
if (Conf.adminBypassPlayers.contains(player.getName()))
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing())
{
return true;
}
@ -354,11 +354,11 @@ public class FactionsPlayerListener extends PlayerListener
}
}
FPlayer me = FPlayers.i.get(player);
if (otherFaction.isNone())
{
if (!Conf.wildernessDenyUseage || Permission.ADMIN_BYPASS.has(player) || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
{
return true; // This is not faction territory. Use whatever you like here.
}
@ -422,8 +422,8 @@ public class FactionsPlayerListener extends PlayerListener
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck)
{
if (Conf.adminBypassPlayers.contains(player.getName()))
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing())
{
return true;
}
@ -454,7 +454,7 @@ public class FactionsPlayerListener extends PlayerListener
}
}
FPlayer me = FPlayers.i.get(player);
Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelation(otherFaction);
boolean ownershipFail = Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc);
@ -575,7 +575,7 @@ public class FactionsPlayerListener extends PlayerListener
&&
! Conf.territoryNeutralDenyCommands.isEmpty()
&&
! Conf.adminBypassPlayers.contains(me.getName())
! me.isAdminBypassing()
)
{
Iterator<String> iter = Conf.territoryNeutralDenyCommands.iterator();
@ -603,7 +603,7 @@ public class FactionsPlayerListener extends PlayerListener
&&
! Conf.territoryEnemyDenyCommands.isEmpty()
&&
! Conf.adminBypassPlayers.contains(me.getName())
! me.isAdminBypassing()
)
{
Iterator<String> iter = Conf.territoryEnemyDenyCommands.iterator();

View File

@ -11,7 +11,6 @@ public enum Permission
VIEW_ANY_POWER("viewAnyPower"),
VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"),
PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"),
ADMIN_BYPASS("adminBypass"),
CONFIG("config"),
DISBAND("disband"),
LOCK("lock"),
@ -22,11 +21,13 @@ public enum Permission
SAVE_ALL("saveall"),
SET_PEACEFUL("setPeaceful"),
SET_PERMANENT("setPermanent"),
COMMAND_ADMIN("command.admin"),
COMMAND_AUTOCLAIM("command.autoClaim"),
COMMAND_BALANCE("command.balance"),
COMMAND_WITHDRAW("command.withdraw"),
COMMAND_PAY("command.pay"),
COMMAND_BYPASS("command.bypass"),
COMMAND_CHAT("command.chat"),
COMMAND_CLAIM("command.claim"),
COMMAND_CONFIG("command.config"),
@ -46,6 +47,24 @@ public enum Permission
COMMAND_LOCK("command.lock"),
COMMAND_MAP("command.map"),
COMMAND_MOD("command.mod"),
COMMAND_NO_BOOM("command.noBoom"),
COMMAND_OPEN("command.open"),
COMMAND_OWNER("command.owner"),
COMMAND_OWNERLIST("command.ownerlist"),
COMMAND_SET_PEACEFUL("command.setPeaceful"),
COMMAND_SET_PERMANENT("command.setPermanent"),
COMMAND_POWER("command.power"),
COMMAND_POWER_ANY("command.power.any"),
COMMAND_RELATION("command.relation"),
COMMAND_RELOAD("command.reload"),
COMMAND_SAVE("command.save"),
COMMAND_SETHOME("command.sethome"),
COMMAND_SETHOME_ANY("command.sethome.any"),
COMMAND_SHOW("command.show"),
COMMAND_TAG("command.tag"),
COMMAND_TITLE("command.title"),
COMMAND_UNCLAIM("command.unclaim"),
COMMAND_VERSION("command.version"),
;
public final String node;

View File

@ -163,4 +163,20 @@ public enum Relation
return Conf.territoryDenyUseage;
}
}
public double getRelationCost()
{
if (isEnemy())
{
return Conf.econCostEnemy;
}
else if (isAlly())
{
return Conf.econCostAlly;
}
else
{
return Conf.econCostNeutral;
}
}
}

View File

@ -79,7 +79,7 @@ public abstract class MPlugin extends JavaPlugin
long saveTicks = 20 * 60 * 30; // Approximately every 30 min
if (saveTask == null)
{
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(), saveTicks, saveTicks);
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
}
return true;
@ -220,6 +220,18 @@ public abstract class MPlugin extends JavaPlugin
return false;
}
// -------------------------------------------- //
// HOOKS
// -------------------------------------------- //
public void preSaveTask()
{
}
public void postSaveTask()
{
}
// -------------------------------------------- //
// LOGGING

View File

@ -1,9 +1,19 @@
package com.massivecraft.factions.zcore.persist;
import com.massivecraft.factions.zcore.MPlugin;
public class SaveTask implements Runnable
{
MPlugin p;
public SaveTask(MPlugin p)
{
this.p = p;
}
public void run()
{
p.preSaveTask();
EM.saveAllToDisc();
p.postSaveTask();
}
}

View File

@ -44,21 +44,12 @@ permissions:
factions.create:
description: create a new faction
default: true
factions.viewAnyPower:
description: view the power level of anyone else
default: true
factions.viewAnyFactionBalance:
description: view the faction bank balance for any faction
default: true
factions.peacefulExplosionToggle:
description: disable explosions in your territory as a peaceful faction admin or moderator
default: true
factions.adminBypass:
description: enable admin bypass mode (build/destroy anywhere)
default: op
factions.config:
description: use /f config command to change conf.json options
default: op
factions.manageSafeZone:
description: claim land as a safe zone and build/destroy within safe zones
default: op
@ -68,18 +59,7 @@ permissions:
factions.ownershipBypass:
description: bypass ownership restrictions within own faction's territory
default: op
factions.reload:
description: use the /f reload command to reload data file(s) from disk
default: op
factions.saveall:
description: use the /f saveall command to save all data to disk
default: op
factions.setPeaceful:
description: designate specific factions as "peaceful" (no PvP, no land stealing, etc.)
default: op
factions.setPermanent:
description: designate specific factions as permanent (not disbanded even with no members)
default: op
factions.command.admin:
description: hand over your admin rights
@ -96,6 +76,9 @@ permissions:
factions.command.pay:
description: pay another faction from your bank
default: true
factions.command.bypass:
description: enable admin bypass mode
default: op
factions.command.chat:
description: change chat mode
default: true
@ -150,3 +133,59 @@ permissions:
factions.command.mod:
description: give or revoke moderator rights
default: true
factions.command.noBoom:
description: toggle explosions (peaceful factions only)
default: true
factions.command.open:
description: switch if invitation is required to join
default: true
factions.command.owner:
description: set ownership of claimed land
default: true
factions.command.ownerlist:
description: list owner(s) of this claimed land
default: true
factions.command.setPeaceful:
description: designate a faction as peaceful
default: op
factions.command.setPermanent:
description: designate a faction as permanent
default: op
factions.command.power:
description: show player power info
default: true
factions.command.power.any:
description: view an other players power level
default: true
factions.command.relation:
description: set relation wish to another faction
default: true
factions.command.reload:
description: reload data file(s) from disk
default: op
factions.command.save:
description: save all data to disk
default: op
factions.command.sethome:
description: set the faction home
default: true
factions.command.sethome.any:
description: set any faction home
default: op
factions.command.show:
description: chow faction information
default: true
factions.command.tag:
description: change the faction tag
default: true
factions.command.title:
description: set or remove a players title
default: true
factions.command.version:
description: see the version of the plugin
default: true
factions.command.unclaim:
description: unclaim the land where you are standing
default: true