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 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 List<String> baseCommandAliases = new ArrayList<String>();
public static boolean allowNoSlashCommand = true; public static boolean allowNoSlashCommand = true;

View File

@ -8,7 +8,8 @@ import org.bukkit.entity.Player;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
public class FLocation { public class FLocation
{
private String worldName = "world"; private String worldName = "world";
private int x = 0; private int x = 0;
@ -20,31 +21,37 @@ public class FLocation {
// Constructors // 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.worldName = worldName;
this.x = x; this.x = x;
this.z = z; 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)); // this(location.getWorld().getName(), (int) Math.floor(location.getX() / cellSize) , (int) Math.floor(location.getZ() / cellSize));
// handy dandy rapid bitshifting instead of division // handy dandy rapid bitshifting instead of division
this(location.getWorld().getName(), location.getBlockX() >> 4, location.getBlockZ() >> 4); this(location.getWorld().getName(), location.getBlockX() >> 4, location.getBlockZ() >> 4);
} }
public FLocation(Player player) { public FLocation(Player player)
{
this(player.getLocation()); this(player.getLocation());
} }
public FLocation(FPlayer fplayer) { public FLocation(FPlayer fplayer)
{
this(fplayer.getPlayer()); this(fplayer.getPlayer());
} }
public FLocation(Block block) { public FLocation(Block block)
{
this(block.getLocation()); this(block.getLocation());
} }
@ -52,31 +59,38 @@ public class FLocation {
// Getters and Setters // Getters and Setters
//----------------------------------------------// //----------------------------------------------//
public String getWorldName() { public String getWorldName()
{
return worldName; return worldName;
} }
public void setWorldName(String worldName) { public void setWorldName(String worldName)
{
this.worldName = worldName; this.worldName = worldName;
} }
public long getX() { public long getX()
{
return x; return x;
} }
public void setX(int x) { public void setX(int x)
{
this.x = x; this.x = x;
} }
public long getZ() { public long getZ()
{
return z; return z;
} }
public void setZ(int z) { public void setZ(int z)
{
this.z = z; this.z = z;
} }
public String getCoordString() { public String getCoordString()
{
return ""+x+","+z; return ""+x+","+z;
} }
@ -93,11 +107,14 @@ public class FLocation {
return new FLocation(this.worldName, this.x + dx, this.z + dz); 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>(); HashSet<FLocation> ret = new HashSet<FLocation>();
for (long x : MiscUtil.range(from.getX(), to.getX())) { for (long x : MiscUtil.range(from.getX(), to.getX()))
for (long z : MiscUtil.range(from.getZ(), to.getZ())) { {
for (long z : MiscUtil.range(from.getZ(), to.getZ()))
{
ret.add(new FLocation(from.getWorldName(), (int)x, (int)z)); ret.add(new FLocation(from.getWorldName(), (int)x, (int)z));
} }
} }
@ -110,7 +127,8 @@ public class FLocation {
//----------------------------------------------// //----------------------------------------------//
@Override @Override
public int hashCode() { public int hashCode()
{
int hash = 3; int hash = 3;
hash = 19 * hash + (this.worldName != null ? this.worldName.hashCode() : 0); hash = 19 * hash + (this.worldName != null ? this.worldName.hashCode() : 0);
hash = 19 * hash + this.x; hash = 19 * hash + this.x;
@ -119,7 +137,8 @@ public class FLocation {
}; };
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj)
{
if (obj == this) if (obj == this)
return true; return true;
if (!(obj instanceof FLocation)) 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 // FIELD: loginPvpDisabled
private transient boolean 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 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; double cost = Conf.econCostLeave;
// pay up // pay up
@ -625,7 +629,7 @@ public class FPlayer extends PlayerEntity
return false; 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."); sendMessage("Your faction must have at least "+Conf.claimsRequireMinFactionMembers+" members to claim land.");
return false; return false;
@ -667,7 +671,7 @@ public class FPlayer extends PlayerEntity
if if
( (
Conf.claimsMustBeConnected Conf.claimsMustBeConnected
&& !Conf.adminBypassPlayers.contains(this.getId()) && ! this.isAdminBypassing()
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
&& !Board.isConnectedLocation(flocation, myFaction) && !Board.isConnectedLocation(flocation, myFaction)
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !otherFaction.isNormal()) && (!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 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()); double cost = Econ.calculateClaimCost(ownedLand, otherFaction.isNormal());
String costString = Econ.moneyString(cost); String costString = Econ.moneyString(cost);

View File

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

View File

@ -197,10 +197,19 @@ public class P extends MPlugin
@Override @Override
public void onDisable() public void onDisable()
{ {
Board.save();
Conf.save();
unhookEssentialsChat(); unhookEssentialsChat();
super.onDisable(); super.onDisable();
} }
@Override
public void postSaveTask()
{
Board.save();
Conf.save();
}
// -------------------------------------------- // // -------------------------------------------- //
// Integration with other plugins // 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 FPlayer fme;
public Faction myFaction;
public boolean senderMustBeMember; public boolean senderMustBeMember;
public boolean senderMustBeModerator; public boolean senderMustBeModerator;
public boolean senderMustBeAdmin; public boolean senderMustBeAdmin;
@ -49,10 +50,12 @@ public abstract class FCommand extends MCommand<P>
if (sender instanceof Player) if (sender instanceof Player)
{ {
this.fme = FPlayers.i.get((Player)sender); this.fme = FPlayers.i.get((Player)sender);
this.myFaction = this.fme.getFaction();
} }
else else
{ {
this.fme = null; this.fme = null;
this.myFaction = null;
} }
super.execute(sender, args, commandChain); 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 // 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) 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; return true;
} }

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
@ -36,8 +35,6 @@ public class FCommandAdmin extends FCommand
FPlayer fyou = this.argAsBestFPlayerMatch(0); FPlayer fyou = this.argAsBestFPlayerMatch(0);
if (fyou == null) return; if (fyou == null) return;
Faction myFaction = fme.getFaction();
if (fyou.getFaction() != myFaction) if (fyou.getFaction() != myFaction)
{ {
sendMessageParsed("%s<i> is not a member in your faction.", fyou.getNameAndRelevant(fme)); 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.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
public class FCommandAutoClaim extends FCommand public class FCommandAutoClaim extends FCommand
@ -42,7 +41,6 @@ public class FCommandAutoClaim extends FCommand
return; return;
} }
Faction myFaction = fme.getFaction();
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(fme);
if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) if (Conf.worldsNoClaiming.contains(flocation.getWorldName()))

View File

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

View File

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

View File

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

View File

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

View File

@ -33,10 +33,10 @@ public class FCommandDisband extends FCommand
public void perform() public void perform()
{ {
// The faction, default to your own.. but null if console sender. // 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; if (faction == null) return;
boolean isMyFaction = fme == null ? false : faction == fme.getFaction(); boolean isMyFaction = fme == null ? false : faction == myFaction;
if (isMyFaction) if (isMyFaction)
{ {

View File

@ -49,8 +49,6 @@ public class FCommandHome extends FCommand
return; return;
} }
Faction myFaction = fme.getFaction();
if ( ! myFaction.hasHome()) if ( ! myFaction.hasHome())
{ {
fme.sendMessage("You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); 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.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
public class FCommandInvite extends FCommand public class FCommandInvite extends FCommand
@ -36,8 +35,6 @@ public class FCommandInvite extends FCommand
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return; if (you == null) return;
Faction myFaction = fme.getFaction();
if (you.getFaction() == myFaction) if (you.getFaction() == myFaction)
{ {
sendMessageParsed("%s<i> is already a member of %s", you.getName(), myFaction.getTag()); 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; return;
} }
if (faction == fme.getFaction()) if (faction == myFaction)
{ {
sendMessageParsed("<b>You are already a member of %s", faction.getTag(fme)); sendMessageParsed("<b>You are already a member of %s", faction.getTag(fme));
return; return;

View File

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

View File

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

View File

@ -1,58 +1,49 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
public class FCommandNoBoom extends FCommand { public class FCommandNoBoom extends FCommand
{
public FCommandNoBoom()
{
super();
this.aliases.add("noboom");
public FCommandNoBoom() { //this.requiredArgs.add("");
aliases.add("noboom"); 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 @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermPeacefulExplosionToggle(sender); {
} if( isLocked() )
{
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.MODERATOR)) { if ( ! myFaction.isPeaceful())
return; {
} fme.sendMessageParsed("<b>This command is only usable by factions which are specially designated as peaceful.");
Faction myFaction = fme.getFaction();
if (!myFaction.isPeaceful()) {
fme.sendMessage("This command is only usable by factions which are specially designated as peaceful.");
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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)) { if ( ! payForCommand(Conf.econCostNoBoom)) return;
return;
}
myFaction.setPeacefulExplosions(); myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled()));
String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled"; String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled";
// Inform // 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.Conf;
import com.massivecraft.factions.Faction; 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() { //this.requiredArgs.add("");
aliases.add("open"); this.optionalArgs.put("yes/no", "flipp");
aliases.add("close");
helpDescription = "Switch if invitation is required to join"; this.permission = Permission.COMMAND_OPEN.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; 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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOpen)) if ( ! payForCommand(Conf.econCostOpen)) return;
{
return;
}
Faction myFaction = fme.getFaction(); myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen()));
myFaction.setOpen( ! fme.getFaction().getOpen());
String open = myFaction.getOpen() ? "open" : "closed"; String open = myFaction.getOpen() ? "open" : "closed";
// Inform // Inform
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open); myFaction.sendMessageParsed("%s<i> changed the faction to ", fme.getNameAndRelevant(myFaction));
for (Faction faction : Faction.getAll()) { for (Faction faction : Factions.i.get())
if (faction == fme.getFaction()) { {
if (faction == myFaction)
{
continue; 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.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandOwner extends FCommand { public class FCommandOwner extends FCommand
{
public FCommandOwner() { public FCommandOwner()
aliases.add("owner"); {
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 @Override
public void perform() { public void perform()
boolean hasBypass = P.hasPermAdminBypass(fme); {
if( isLocked() )
{
sendLockMessage();
return;
}
boolean hasBypass = fme.isAdminBypassing();
if ( ! hasBypass && ! assertHasFaction()) { if ( ! hasBypass && ! assertHasFaction()) {
return; return;
} }
if( isLocked() ) { if ( ! Conf.ownedAreasEnabled)
sendLockMessage(); {
fme.sendMessageParsed("<b>Sorry, but owned areas are disabled on this server.");
return; return;
} }
if ( ! Conf.ownedAreasEnabled) { if ( ! hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction)
fme.sendMessage("Sorry, but owned areas are disabled on this server."); {
fme.sendMessageParsed("<b>Sorry, but you have reached the server's <h>limit of %d <b>owned areas per faction.", Conf.ownedAreasLimitPerFaction);
return; return;
} }
Faction myFaction = fme.getFaction(); if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN))
{
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)) {
return; return;
} }
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(fme);
if (Board.getIdAt(flocation) != myFaction.getId()) { Faction factionHere = Board.getFactionAt(flocation);
if (!hasBypass) { if (factionHere != myFaction)
fme.sendMessage("This land is not claimed by your faction, so you can't set ownership of it."); {
if ( ! hasBypass)
{
fme.sendMessageParsed("<b>This land is not claimed by your faction, so you can't set ownership of it.");
return; return;
} }
myFaction = Board.getFactionAt(flocation); if ( ! factionHere.isNormal())
if (!myFaction.isNormal()) { {
fme.sendMessage("This land is not claimed by a faction. Ownership is not possible."); fme.sendMessageParsed("<b>This land is not claimed by a faction. Ownership is not possible.");
return; return;
} }
} }
FPlayer target; FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) return;
if (parameters.size() > 0) {
target = findFPlayer(parameters.get(0), false);
} else {
target = fme;
}
if (target == null) {
return;
}
String playerName = target.getName(); String playerName = target.getName();
if (target.getFaction().getId() != myFaction.getId()) { if (target.getFaction() != myFaction)
fme.sendMessage(playerName + " is not a member of this faction."); {
fme.sendMessageParsed("%s<i> is not a member of this faction.", playerName);
return; return;
} }
// if no player name was passed, and this claim does already have owners set, clear them // 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); 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; return;
} }
if (myFaction.isPlayerInOwnerList(playerName, flocation)) { if (myFaction.isPlayerInOwnerList(playerName, flocation))
{
myFaction.removePlayerAsOwner(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; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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)) { if ( ! payForCommand(Conf.econCostOwner)) return;
return;
}
myFaction.setPlayerAsOwner(playerName, flocation); 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; package com.massivecraft.factions.commands;
import java.util.Set;
import java.util.Iterator;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.P;
public class FCommandOwnerList extends FCommand { public class FCommandOwnerList extends FCommand
{
public FCommandOwnerList() { public FCommandOwnerList()
aliases.add("ownerlist"); {
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 @Override
public void perform() { public void perform()
boolean hasBypass = P.hasPermAdminBypass(fme); {
boolean hasBypass = fme.isAdminBypassing();
if ( ! hasBypass && ! assertHasFaction()) { if ( ! hasBypass && ! assertHasFaction())
{
return; return;
} }
if ( ! Conf.ownedAreasEnabled) { if ( ! Conf.ownedAreasEnabled)
fme.sendMessage("Owned areas are disabled on this server."); {
fme.sendMessageParsed("<b>Owned areas are disabled on this server.");
return; return;
} }
Faction myFaction = fme.getFaction();
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(fme);
if (Board.getIdAt(flocation) != myFaction.getId()) { if (Board.getIdAt(flocation) != myFaction.getId())
if (!hasBypass) { {
fme.sendMessage("This land is not claimed by your faction."); if (!hasBypass)
{
fme.sendMessageParsed("<b>This land is not claimed by your faction.");
return; return;
} }
myFaction = Board.getFactionAt(flocation); myFaction = Board.getFactionAt(flocation);
if (!myFaction.isNormal()) { if (!myFaction.isNormal())
fme.sendMessage("This land is not claimed by any faction, thus no owners."); {
fme.sendMessageParsed("<i>This land is not claimed by any faction, thus no owners.");
return; return;
} }
} }
String owners = myFaction.getOwnerListString(flocation); String owners = myFaction.getOwnerListString(flocation);
if (owners == null || owners.isEmpty()) { if (owners == null || owners.isEmpty())
fme.sendMessage("No owners are set here; everyone in the faction has access."); {
fme.sendMessageParsed("<i>No owners are set here; everyone in the faction has access.");
return; 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("faction");
this.requiredArgs.add("amount"); this.requiredArgs.add("amount");
//this.optionalArgs.put("factiontag", "yours"); //this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_PAY.node; this.permission = Permission.COMMAND_PAY.node;

View File

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

View File

@ -1,57 +1,41 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer; 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() { //this.requiredArgs.add("faction tag");
aliases.add("power"); this.optionalArgs.put("player name", "you");
aliases.add("pow");
this.permission = Permission.COMMAND_POWER.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
optionalParameters.add("player name"); senderMustBeModerator = false;
senderMustBeAdmin = false;
helpDescription = "show player power info";
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return true; {
} FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) return;
@Override if (target != me && ! Permission.COMMAND_POWER_ANY.has(sender, true)) return;
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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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)) { if ( ! payForCommand(Conf.econCostPower)) return;
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; import com.massivecraft.factions.struct.Relation;
public class FCommandRelationAlly extends FRelationCommand { public class FCommandRelationAlly extends FRelationCommand
{
public FCommandRelationAlly() { public FCommandRelationAlly()
{
aliases.add("ally"); 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; import com.massivecraft.factions.struct.Relation;
public class FCommandRelationEnemy extends FRelationCommand { public class FCommandRelationEnemy extends FRelationCommand
{
public FCommandRelationEnemy() { public FCommandRelationEnemy()
{
aliases.add("enemy"); 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; import com.massivecraft.factions.struct.Relation;
public class FCommandRelationNeutral extends FRelationCommand { public class FCommandRelationNeutral extends FRelationCommand
{
public FCommandRelationNeutral() { public FCommandRelationNeutral()
{
aliases.add("neutral"); 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; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class FCommandReload extends FCommand { public class FCommandReload extends FCommand
{
public FCommandReload() { public FCommandReload()
aliases.add("reload"); {
super();
this.aliases.add("reload");
//this.requiredArgs.add("");
this.optionalArgs.put("file", "all");
this.permission = Permission.COMMAND_RELOAD.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
optionalParameters.add("file"); senderMustBeModerator = false;
senderMustBeAdmin = false;
helpDescription = "reloads all json files, or a specific one";
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermReload(sender); {
}
@Override
public void perform() {
P.log("=== RELOAD START ===");
long timeInitStart = System.currentTimeMillis(); long timeInitStart = System.currentTimeMillis();
String fileName = "s"; String file = this.argAsString(0, "all").toLowerCase();
// Was a single file specified? String fileName;
if (parameters.size() > 0) {
String file = parameters.get(0); if (file.startsWith("c"))
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");
Conf.load(); Conf.load();
FPlayer.load(); fileName = "conf.json";
Faction.load(); }
else if (file.startsWith("b"))
{
Board.load(); 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); 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; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission;
public class FCommandSafeclaim extends FCommand { public class FCommandSafeclaim extends FCommand
{
public FCommandSafeclaim() { public FCommandSafeclaim()
aliases.add("safeclaim"); {
aliases.add("safe"); 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 @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermManageSafeZone(sender); {
} if( isLocked() )
{
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
@ -34,31 +38,18 @@ public class FCommandSafeclaim extends FCommand {
// The current location of the player // The current location of the player
FLocation playerFlocation = new FLocation(fme); FLocation playerFlocation = new FLocation(fme);
// Was a radius set? int radius = this.argAsInt(0, 0);
if (parameters.size() > 0) { if (radius < 0) radius = 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;
}
FLocation from = playerFlocation.getRelative(radius, radius); FLocation from = playerFlocation.getRelative(radius, radius);
FLocation to = playerFlocation.getRelative(-radius, -radius); FLocation to = playerFlocation.getRelative(-radius, -radius);
for (FLocation locToClaim : FLocation.getArea(from, to)) { for (FLocation locToClaim : FLocation.getArea(from, to))
Board.setFactionAt(Faction.getSafeZone(), locToClaim); {
} Board.setFactionAt(Factions.i.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.");
} }
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; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission;
public class FCommandSafeunclaimall extends FCommand { public class FCommandSafeunclaimall extends FCommand
{
public FCommandSafeunclaimall() { public FCommandSafeunclaimall()
aliases.add("safeunclaimall"); {
aliases.add("safedeclaimall"); 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 @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermManageSafeZone(sender); {
} if( isLocked() )
{
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
Board.unclaimAll(Faction.getSafeZone().getId()); Board.unclaimAll(Factions.i.getSafeZone().getId());
sendMessage("You unclaimed ALL safe zone land."); sendMessageParsed("<i>You unclaimed ALL safe zone land.");
} }
} }

View File

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

View File

@ -1,72 +1,81 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandSethome extends FCommand { public class FCommandSethome extends FCommand
{
public FCommandSethome()
{
this.aliases.add("sethome");
public FCommandSethome() { //this.requiredArgs.add("");
aliases.add("sethome"); 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 @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.MODERATOR)) { if ( ! Conf.homesEnabled)
{
fme.sendMessageParsed("<b>Sorry, Faction homes are disabled on this server.");
return; return;
} }
if ( ! Conf.homesEnabled) { Faction faction = this.argAsFaction(0, myFaction);
fme.sendMessage("Sorry, Faction homes are disabled on this server."); if (faction == null) return;
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(); // Can the player set the faction home HERE?
if
if (parameters.size() > 0) { (
if (!P.hasPermAdminBypass(fme)) { ! Permission.COMMAND_BYPASS.has(me)
fme.sendMessage("You cannot set the home of another faction without adminBypass permission."); &&
return; Conf.homesMustBeInClaimedTerritory
} &&
Board.getFactionAt(new FLocation(me)) != faction
myFaction = findFaction(parameters.get(0), true); )
{
if (myFaction == null) { fme.sendMessageParsed("<b>Sorry, your faction home can only be set inside your own claimed territory.");
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.");
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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)) { if ( ! payForCommand(Conf.econCostSethome)) return;
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:"); faction.sendMessage(fme.getNameAndRelevant(myFaction)+"<i> set the home for your faction. You can now use:");
myFaction.sendMessage(new FCommandHome().getUseageTemplate()); faction.sendMessage(new FCommandHome().getUseageTemplate());
if (myFaction != fme.getFaction()) { if (faction != myFaction)
fme.sendMessage("You have set the home for the "+myFaction.getTag(fme)+Conf.colorSystem+" faction."); {
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 java.util.Collection;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; 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.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() { //this.requiredArgs.add("");
aliases.add("show"); this.optionalArgs.put("faction tag", "yours");
aliases.add("who");
senderMustBePlayer = false; this.permission = Permission.COMMAND_SHOW.node;
optionalParameters.add("faction tag"); senderMustBePlayer = true;
senderMustBeMember = false;
helpDescription = "Show faction information"; senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return true; {
} Faction faction = this.argAsFaction(0, myFaction);
if (faction == null) return;
@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;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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)) { if ( ! payForCommand(Conf.econCostShow)) return;
return;
}
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN); Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR); Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL); Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
sendMessage(TextUtil.titleize(faction.getTag(fme))); sendMessageParsed(p.txt.titleize(faction.getTag(fme)));
sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription()); sendMessageParsed("<a>Description: <i>%s", faction.getDescription());
if ( ! faction.isNormal()) { if ( ! faction.isNormal())
{
return; return;
} }
String peaceStatus = ""; String peaceStatus = "";
if (faction.isPeaceful()) { if (faction.isPeaceful())
{
peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful"; peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful";
} }
sendMessage(Conf.colorChrome+"Joining: "+Conf.colorSystem+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus); sendMessageParsed("<a>Joining: <i>"+(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>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
if (faction.isPermanent()) { if (faction.isPermanent())
sendMessage(Conf.colorChrome+"This faction is permanent, remaining even with no members."); {
sendMessageParsed("<a>This faction is permanent, remaining even with no members.");
} }
// show the land value // show the land value
if (Econ.enabled()) { if (Econ.enabled())
{
double value = Econ.calculateTotalLandValue(faction.getLandRounded()); double value = Econ.calculateTotalLandValue(faction.getLandRounded());
double refund = value * Conf.econClaimRefundMultiplier; double refund = value * Conf.econClaimRefundMultiplier;
if (value > 0) { if (value > 0)
{
String stringValue = Econ.moneyString(value); String stringValue = Econ.moneyString(value);
String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : ""; 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 //Show bank contents
if(Conf.bankEnabled) { 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; String listpart;
// List relation // List relation
String allyList = Conf.colorChrome+"Allies: "; String allyList = p.txt.parse("<a>Allies: ");
String enemyList = Conf.colorChrome+"Enemies: "; String enemyList = p.txt.parse("<a>Enemies: ");
for (Faction otherFaction : Faction.getAll()) { for (Faction otherFaction : Factions.i.get())
if (otherFaction == faction) { {
if (otherFaction == faction)
{
continue; continue;
} }
listpart = otherFaction.getTag(fme)+Conf.colorSystem+", "; listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
if (otherFaction.getRelation(faction).isAlly()) { if (otherFaction.getRelation(faction).isAlly())
{
allyList += listpart; allyList += listpart;
} else if (otherFaction.getRelation(faction).isEnemy()) { }
else if (otherFaction.getRelation(faction).isEnemy())
{
enemyList += listpart; enemyList += listpart;
} }
} }
if (allyList.endsWith(", ")) { if (allyList.endsWith(", "))
{
allyList = allyList.substring(0, allyList.length()-2); allyList = allyList.substring(0, allyList.length()-2);
} }
if (enemyList.endsWith(", ")) { if (enemyList.endsWith(", "))
{
enemyList = enemyList.substring(0, enemyList.length()-2); enemyList = enemyList.substring(0, enemyList.length()-2);
} }
@ -117,26 +115,33 @@ public class FCommandShow extends FCommand {
sendMessage(enemyList); sendMessage(enemyList);
// List the members... // List the members...
String onlineList = Conf.colorChrome+"Members online: "; String onlineList = p.txt.parse("<a>")+"Members online: ";
String offlineList = Conf.colorChrome+"Members offline: "; String offlineList = p.txt.parse("<a>")+"Members offline: ";
for (FPlayer follower : admins) { for (FPlayer follower : admins)
listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; {
if (follower.isOnline()) { listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if (follower.isOnline())
{
onlineList += listpart; onlineList += listpart;
} else { }
else
{
offlineList += listpart; offlineList += listpart;
} }
} }
for (FPlayer follower : mods) { for (FPlayer follower : mods)
listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; {
if (follower.isOnline()) { listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if
(follower.isOnline())
{
onlineList += listpart; onlineList += listpart;
} else { } else {
offlineList += listpart; offlineList += listpart;
} }
} }
for (FPlayer follower : normals) { for (FPlayer follower : normals) {
listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if (follower.isOnline()) { if (follower.isOnline()) {
onlineList += listpart; onlineList += listpart;
} else { } else {

View File

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

View File

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

View File

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

View File

@ -1,28 +1,29 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.P; 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() { //this.requiredArgs.add("");
aliases.add("version"); //this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_VERSION.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
helpDescription = "Which version are you using?"; senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return true; {
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; return;
} }
Faction faction = fme.getFaction(); Faction faction = myFaction;
double amount = this.argAsDouble(0, 0d); 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.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; 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() { this.permission = Permission.COMMAND_RELATION.node;
requiredParameters.add("faction tag");
helpDescription = "Set relation wish to another faction"; senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
public void relation(Relation whishedRelation, String otherFactionName) { @Override
if ( ! assertHasFaction()) { public void perform()
return; {
} if( isLocked() )
{
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.MODERATOR)) { Faction them = this.argAsFaction(0);
if ( ! them.isNormal())
{
sendMessageParsed("<b>Nope! You can't.");
return; return;
} }
Faction myFaction = fme.getFaction(); if (them == myFaction)
Faction otherFaction = findFaction(otherFactionName, false); {
if (otherFaction == null) { sendMessageParsed("<b>Nope! You can't declare a relation to yourself :)");
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 :)");
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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(targetRelation.getRelationCost())) return;
if (!payForCommand(cost)) {
return;
}
myFaction.setRelationWish(otherFaction, whishedRelation); myFaction.setRelationWish(them, targetRelation);
Relation currentRelation = myFaction.getRelation(otherFaction, true); Relation currentRelation = myFaction.getRelation(them, true);
ChatColor currentRelationColor = currentRelation.getColor(); ChatColor currentRelationColor = currentRelation.getColor();
if (whishedRelation.value == currentRelation.value) { if (targetRelation.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()); them.sendMessageParsed("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+myFaction.getTag());
} else { myFaction.sendMessageParsed("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+them.getTag());
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 (!whishedRelation.isNeutral() && otherFaction.isPeaceful()) { else
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."); 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.");
if (!whishedRelation.isNeutral() && myFaction.isPeaceful()) { myFaction.sendMessageParsed(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
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.");
} }
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) 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; return true;
} }
FLocation loc = new FLocation(location); FLocation loc = new FLocation(location);
Faction otherFaction = Board.getFactionAt(loc); Faction otherFaction = Board.getFactionAt(loc);
FPlayer me = FPlayers.i.get(player);
if (otherFaction.isNone()) 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. 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) public boolean playerCanDoPaintings(Player player, FLocation loc, String action)
{ {
FPlayer me = FPlayers.i.get(player);
if (Conf.adminBypassPlayers.contains(player.getName())) if (me.isAdminBypassing())
{ {
return true; return true;
} }
Faction otherFaction = Board.getFactionAt(loc); Faction otherFaction = Board.getFactionAt(loc);
FPlayer me = FPlayers.i.get(player);
if (otherFaction.isNone()) 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. 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) public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck)
{ {
FPlayer me = FPlayers.i.get(player);
if (Conf.adminBypassPlayers.contains(player.getName())) if (me.isAdminBypassing())
{ {
return true; return true;
} }
@ -354,11 +354,11 @@ public class FactionsPlayerListener extends PlayerListener
} }
} }
FPlayer me = FPlayers.i.get(player);
if (otherFaction.isNone()) 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. 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) public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck)
{ {
FPlayer me = FPlayers.i.get(player);
if (Conf.adminBypassPlayers.contains(player.getName())) if (me.isAdminBypassing())
{ {
return true; return true;
} }
@ -454,7 +454,7 @@ public class FactionsPlayerListener extends PlayerListener
} }
} }
FPlayer me = FPlayers.i.get(player);
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelation(otherFaction); Relation rel = myFaction.getRelation(otherFaction);
boolean ownershipFail = Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc); boolean ownershipFail = Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc);
@ -575,7 +575,7 @@ public class FactionsPlayerListener extends PlayerListener
&& &&
! Conf.territoryNeutralDenyCommands.isEmpty() ! Conf.territoryNeutralDenyCommands.isEmpty()
&& &&
! Conf.adminBypassPlayers.contains(me.getName()) ! me.isAdminBypassing()
) )
{ {
Iterator<String> iter = Conf.territoryNeutralDenyCommands.iterator(); Iterator<String> iter = Conf.territoryNeutralDenyCommands.iterator();
@ -603,7 +603,7 @@ public class FactionsPlayerListener extends PlayerListener
&& &&
! Conf.territoryEnemyDenyCommands.isEmpty() ! Conf.territoryEnemyDenyCommands.isEmpty()
&& &&
! Conf.adminBypassPlayers.contains(me.getName()) ! me.isAdminBypassing()
) )
{ {
Iterator<String> iter = Conf.territoryEnemyDenyCommands.iterator(); Iterator<String> iter = Conf.territoryEnemyDenyCommands.iterator();

View File

@ -11,7 +11,6 @@ public enum Permission
VIEW_ANY_POWER("viewAnyPower"), VIEW_ANY_POWER("viewAnyPower"),
VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"), VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"),
PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"), PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"),
ADMIN_BYPASS("adminBypass"),
CONFIG("config"), CONFIG("config"),
DISBAND("disband"), DISBAND("disband"),
LOCK("lock"), LOCK("lock"),
@ -22,11 +21,13 @@ public enum Permission
SAVE_ALL("saveall"), SAVE_ALL("saveall"),
SET_PEACEFUL("setPeaceful"), SET_PEACEFUL("setPeaceful"),
SET_PERMANENT("setPermanent"), SET_PERMANENT("setPermanent"),
COMMAND_ADMIN("command.admin"), COMMAND_ADMIN("command.admin"),
COMMAND_AUTOCLAIM("command.autoClaim"), COMMAND_AUTOCLAIM("command.autoClaim"),
COMMAND_BALANCE("command.balance"), COMMAND_BALANCE("command.balance"),
COMMAND_WITHDRAW("command.withdraw"), COMMAND_WITHDRAW("command.withdraw"),
COMMAND_PAY("command.pay"), COMMAND_PAY("command.pay"),
COMMAND_BYPASS("command.bypass"),
COMMAND_CHAT("command.chat"), COMMAND_CHAT("command.chat"),
COMMAND_CLAIM("command.claim"), COMMAND_CLAIM("command.claim"),
COMMAND_CONFIG("command.config"), COMMAND_CONFIG("command.config"),
@ -46,6 +47,24 @@ public enum Permission
COMMAND_LOCK("command.lock"), COMMAND_LOCK("command.lock"),
COMMAND_MAP("command.map"), COMMAND_MAP("command.map"),
COMMAND_MOD("command.mod"), 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; public final String node;

View File

@ -163,4 +163,20 @@ public enum Relation
return Conf.territoryDenyUseage; 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 long saveTicks = 20 * 60 * 30; // Approximately every 30 min
if (saveTask == null) 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; return true;
@ -220,6 +220,18 @@ public abstract class MPlugin extends JavaPlugin
return false; return false;
} }
// -------------------------------------------- //
// HOOKS
// -------------------------------------------- //
public void preSaveTask()
{
}
public void postSaveTask()
{
}
// -------------------------------------------- // // -------------------------------------------- //
// LOGGING // LOGGING

View File

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

View File

@ -44,21 +44,12 @@ permissions:
factions.create: factions.create:
description: create a new faction description: create a new faction
default: true default: true
factions.viewAnyPower:
description: view the power level of anyone else
default: true
factions.viewAnyFactionBalance: factions.viewAnyFactionBalance:
description: view the faction bank balance for any faction description: view the faction bank balance for any faction
default: true default: true
factions.peacefulExplosionToggle: factions.peacefulExplosionToggle:
description: disable explosions in your territory as a peaceful faction admin or moderator description: disable explosions in your territory as a peaceful faction admin or moderator
default: true 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: factions.manageSafeZone:
description: claim land as a safe zone and build/destroy within safe zones description: claim land as a safe zone and build/destroy within safe zones
default: op default: op
@ -68,18 +59,7 @@ permissions:
factions.ownershipBypass: factions.ownershipBypass:
description: bypass ownership restrictions within own faction's territory description: bypass ownership restrictions within own faction's territory
default: op 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: factions.command.admin:
description: hand over your admin rights description: hand over your admin rights
@ -96,6 +76,9 @@ permissions:
factions.command.pay: factions.command.pay:
description: pay another faction from your bank description: pay another faction from your bank
default: true default: true
factions.command.bypass:
description: enable admin bypass mode
default: op
factions.command.chat: factions.command.chat:
description: change chat mode description: change chat mode
default: true default: true
@ -150,3 +133,59 @@ permissions:
factions.command.mod: factions.command.mod:
description: give or revoke moderator rights description: give or revoke moderator rights
default: true 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