Laundry list of changes for 1.2.0 release:

/f map now has a nifty faction name key  (LexManos)
There are now War Zones; these work similar to Safe Zones, except PvP is enabled and monsters are not blocked  (Brettflan)
Players now only regenerate power while actually online  (Brettflan)
New command available to prevent power loss in specific worlds  (Brettflan)
New command available to prevent faction land claims in specific worlds (doesn't affect safezone and warzone claims)  (Brettflan)
New command to unclaim all safezone areas  (Brettflan)
Players are now prevented from using /f home if an enemy is nearby, and the players isn't in a safezone or their own faction territory  (Brettflan)
New option to make membership default to closed for newly created factions  (Brettflan)
When an admin has bypass mode enabled (/f bypass), they can now unclaim any faction land they're standing on  (Brettflan)
This commit is contained in:
Brettflan 2011-05-29 16:28:29 -05:00
parent 72c3220d4a
commit b490c5f196
19 changed files with 423 additions and 51 deletions

View File

@ -1,5 +1,5 @@
name: Factions name: Factions
version: 1.1.8 version: 1.2.0
main: org.mcteam.factions.Factions main: org.mcteam.factions.Factions
commands: commands:
f: f:

View File

@ -130,6 +130,13 @@ public class Board {
int width = halfWidth * 2 + 1; int width = halfWidth * 2 + 1;
int height = halfHeight * 2 + 1; int height = halfHeight * 2 + 1;
if (Conf.showMapFactionKey) {
height--;
}
Map<String, Character> fList = new HashMap<String, Character>();
int chrIdx = 0;
// For each row // For each row
for (int dx = 0; dx < height; dx++) { for (int dx = 0; dx < height; dx++) {
// Draw and add that row // Draw and add that row
@ -144,8 +151,13 @@ public class Board {
row += ChatColor.GRAY+"-"; row += ChatColor.GRAY+"-";
} else if (factionHere.isSafeZone()) { } else if (factionHere.isSafeZone()) {
row += ChatColor.GOLD+"+"; row += ChatColor.GOLD+"+";
} else if (factionHere.isWarZone()) {
row += ChatColor.DARK_RED+"+";
} else { } else {
row += factionHere.getRelation(faction).getColor()+"+"; if (!fList.containsKey(factionHere.getTag()))
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
char tag = fList.get(factionHere.getTag());
row += factionHere.getRelation(faction).getColor() + "" + tag;
} }
} }
} }
@ -160,6 +172,15 @@ public class Board {
ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3)); ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3));
ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3)); ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3));
// Add the faction key
if (Conf.showMapFactionKey) {
String fRow = "";
for(String key : fList.keySet()) {
fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key);
}
ret.add(fRow);
}
return ret; return ret;
} }

View File

@ -34,6 +34,10 @@ public class Conf {
public static int factionTagLengthMax = 10; public static int factionTagLengthMax = 10;
public static boolean factionTagForceUpperCase = false; public static boolean factionTagForceUpperCase = false;
public static boolean newFactionsDefaultOpen = true;
public static boolean showMapFactionKey = true;
// Configuration on the Faction tag in chat messages. // Configuration on the Faction tag in chat messages.
public static boolean chatTagEnabled = true; public static boolean chatTagEnabled = true;
@ -48,6 +52,7 @@ public class Conf {
public static boolean homesEnabled = true; public static boolean homesEnabled = true;
public static boolean homesTeleportToOnDeath = true; public static boolean homesTeleportToOnDeath = true;
public static double homesTeleportAllowedEnemyDistance = 32;
public static double territoryShieldFactor = 0.5; public static double territoryShieldFactor = 0.5;
public static boolean territoryBlockCreepers = false; public static boolean territoryBlockCreepers = false;
@ -58,13 +63,24 @@ public class Conf {
public static boolean safeZoneDenyUseage = true; public static boolean safeZoneDenyUseage = true;
public static boolean safeZoneBlockTNT = true; public static boolean safeZoneBlockTNT = true;
public static boolean warZoneBlockCreepers = false;
public static boolean warZoneBlockFireballs = false;
public static boolean warZoneBlockTNT = true;
public static boolean warZoneDenyBuild = true;
public static boolean warZoneDenyUseage = true;
public static boolean warZonePowerLoss = true;
public static Set<Material> territoryProtectedMaterials = new HashSet<Material>(); public static Set<Material> territoryProtectedMaterials = new HashSet<Material>();
public static Set<Material> territoryDenyUseageMaterials = new HashSet<Material>(); public static Set<Material> territoryDenyUseageMaterials = new HashSet<Material>();
public static transient Set<CreatureType> safeZoneNerfedCreatureTypes = new HashSet<CreatureType>(); public static transient Set<CreatureType> safeZoneNerfedCreatureTypes = new HashSet<CreatureType>();
public static Set<String> worldsNoClaiming = new HashSet<String>();
public static Set<String> worldsNoPowerLoss = new HashSet<String>();
public static transient int mapHeight = 8; public static transient int mapHeight = 8;
public static transient int mapWidth = 39; public static transient int mapWidth = 39;
public static transient char[] mapKeyChrs = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
static { static {
territoryProtectedMaterials.add(Material.WOODEN_DOOR); territoryProtectedMaterials.add(Material.WOODEN_DOOR);

View File

@ -131,6 +131,7 @@ public class FPlayer {
public void setLastLoginTime(long lastLoginTime) { public void setLastLoginTime(long lastLoginTime) {
this.lastLoginTime = lastLoginTime; this.lastLoginTime = lastLoginTime;
this.lastPowerUpdateTime = lastLoginTime;
} }
public boolean isMapAutoUpdating() { public boolean isMapAutoUpdating() {
@ -325,6 +326,9 @@ public class FPlayer {
} }
protected void updatePower() { protected void updatePower() {
if (this.isOffline()) {
return;
}
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long millisPassed = now - this.lastPowerUpdateTime; long millisPassed = now - this.lastPowerUpdateTime;
this.lastPowerUpdateTime = now; this.lastPowerUpdateTime = now;

View File

@ -40,7 +40,7 @@ public class Faction {
public Faction() { public Faction() {
this.relationWish = new HashMap<Integer, Relation>(); this.relationWish = new HashMap<Integer, Relation>();
this.invites = new HashSet<String>(); this.invites = new HashSet<String>();
this.open = true; this.open = Conf.newFactionsDefaultOpen;
this.tag = "???"; this.tag = "???";
this.description = "Default faction description :("; this.description = "Default faction description :(";
} }
@ -116,6 +116,10 @@ public class Faction {
return this.getId() == -1; return this.getId() == -1;
} }
public boolean isWarZone() {
return this.getId() == -2;
}
// ------------------------------- // -------------------------------
// Invites - uses lowercase name // Invites - uses lowercase name
// ------------------------------- // -------------------------------
@ -374,7 +378,7 @@ public class Faction {
instances.put(faction.id, faction); instances.put(faction.id, faction);
} }
// Make sure the safe zone faciton exists // Make sure the safe zone faction exists
if ( ! instances.containsKey(-1)) { if ( ! instances.containsKey(-1)) {
Faction faction = new Faction(); Faction faction = new Faction();
faction.tag = ChatColor.GOLD+"Safe Zone"; faction.tag = ChatColor.GOLD+"Safe Zone";
@ -383,6 +387,15 @@ public class Faction {
instances.put(faction.id, faction); instances.put(faction.id, faction);
} }
// Make sure the war zone faction exists
if ( ! instances.containsKey(-2)) {
Faction faction = new Faction();
faction.tag = ChatColor.DARK_RED+"War Zone";
faction.description = "Not the safest place to be";
faction.id = -2;
instances.put(faction.id, faction);
}
return true; return true;
} }
@ -414,6 +427,10 @@ public class Faction {
return instances.get(-1); return instances.get(-1);
} }
public static Faction getWarZone() {
return instances.get(-2);
}
public static boolean exists(Integer factionId) { public static boolean exists(Integer factionId) {
return instances.containsKey(factionId); return instances.containsKey(factionId);
} }

View File

@ -18,39 +18,7 @@ import org.bukkit.event.Event;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.mcteam.factions.commands.FBaseCommand; import org.mcteam.factions.commands.*;
import org.mcteam.factions.commands.FCommandAdmin;
import org.mcteam.factions.commands.FCommandBypass;
import org.mcteam.factions.commands.FCommandChat;
import org.mcteam.factions.commands.FCommandClaim;
import org.mcteam.factions.commands.FCommandCreate;
import org.mcteam.factions.commands.FCommandDeinvite;
import org.mcteam.factions.commands.FCommandDescription;
import org.mcteam.factions.commands.FCommandDisband;
import org.mcteam.factions.commands.FCommandHelp;
import org.mcteam.factions.commands.FCommandHome;
import org.mcteam.factions.commands.FCommandInvite;
import org.mcteam.factions.commands.FCommandJoin;
import org.mcteam.factions.commands.FCommandKick;
import org.mcteam.factions.commands.FCommandLeave;
import org.mcteam.factions.commands.FCommandList;
import org.mcteam.factions.commands.FCommandLock;
import org.mcteam.factions.commands.FCommandMap;
import org.mcteam.factions.commands.FCommandMod;
import org.mcteam.factions.commands.FCommandOpen;
import org.mcteam.factions.commands.FCommandRelationAlly;
import org.mcteam.factions.commands.FCommandRelationEnemy;
import org.mcteam.factions.commands.FCommandRelationNeutral;
import org.mcteam.factions.commands.FCommandReload;
import org.mcteam.factions.commands.FCommandSafeclaim;
import org.mcteam.factions.commands.FCommandSaveAll;
import org.mcteam.factions.commands.FCommandSethome;
import org.mcteam.factions.commands.FCommandShow;
import org.mcteam.factions.commands.FCommandTag;
import org.mcteam.factions.commands.FCommandTitle;
import org.mcteam.factions.commands.FCommandUnclaim;
import org.mcteam.factions.commands.FCommandUnclaimall;
import org.mcteam.factions.commands.FCommandVersion;
import org.mcteam.factions.gson.Gson; import org.mcteam.factions.gson.Gson;
import org.mcteam.factions.gson.GsonBuilder; import org.mcteam.factions.gson.GsonBuilder;
import org.mcteam.factions.listeners.FactionsBlockListener; import org.mcteam.factions.listeners.FactionsBlockListener;
@ -125,8 +93,9 @@ public class Factions extends JavaPlugin {
commands.add(new FCommandRelationEnemy()); commands.add(new FCommandRelationEnemy());
commands.add(new FCommandRelationNeutral()); commands.add(new FCommandRelationNeutral());
commands.add(new FCommandReload()); commands.add(new FCommandReload());
commands.add(new FCommandSaveAll());
commands.add(new FCommandSafeclaim()); commands.add(new FCommandSafeclaim());
commands.add(new FCommandSafeunclaimall());
commands.add(new FCommandSaveAll());
commands.add(new FCommandSethome()); commands.add(new FCommandSethome());
commands.add(new FCommandShow()); commands.add(new FCommandShow());
commands.add(new FCommandTag()); commands.add(new FCommandTag());
@ -134,6 +103,10 @@ public class Factions extends JavaPlugin {
commands.add(new FCommandUnclaim()); commands.add(new FCommandUnclaim());
commands.add(new FCommandUnclaimall()); commands.add(new FCommandUnclaimall());
commands.add(new FCommandVersion()); commands.add(new FCommandVersion());
commands.add(new FCommandWarclaim());
commands.add(new FCommandWarunclaimall());
commands.add(new FCommandWorldNoClaim());
commands.add(new FCommandWorldNoPowerLoss());
// Ensure base folder exists! // Ensure base folder exists!
this.getDataFolder().mkdirs(); this.getDataFolder().mkdirs();
@ -151,6 +124,7 @@ public class Factions extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.High, this); pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this.playerListener, Event.Priority.Normal, this);
@ -218,6 +192,10 @@ public class Factions extends JavaPlugin {
return hasPerm(sender, "factions.manageSafeZone", true); return hasPerm(sender, "factions.manageSafeZone", true);
} }
public static boolean hasPermManageWarZone(CommandSender sender) {
return hasPerm(sender, "factions.manageWarZone", true);
}
public static boolean hasPermAdminBypass(CommandSender sender) { public static boolean hasPermAdminBypass(CommandSender sender) {
return hasPerm(sender, "factions.adminBypass", true); return hasPerm(sender, "factions.adminBypass", true);
} }
@ -238,6 +216,10 @@ public class Factions extends JavaPlugin {
return hasPerm(sender, "factions.disband", true); return hasPerm(sender, "factions.disband", true);
} }
public static boolean hasPermWorlds(CommandSender sender) {
return hasPerm(sender, "factions.worldOptions", true);
}
private static boolean hasPerm(CommandSender sender, String permNode, boolean fallbackOnlyOp) { private static boolean hasPerm(CommandSender sender, String permNode, boolean fallbackOnlyOp) {
if (Factions.Permissions == null || ! (sender instanceof Player)) { if (Factions.Permissions == null || ! (sender instanceof Player)) {
return fallbackOnlyOp == false || sender.isOp(); return fallbackOnlyOp == false || sender.isOp();

View File

@ -39,6 +39,20 @@ public class FCommandClaim extends FBaseCommand {
} }
if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
sendMessage("Sorry, this world has land claiming disabled.");
return;
}
if (otherFaction.isSafeZone()) {
sendMessage("You can not claim a Safe Zone.");
return;
}
else if (otherFaction.isWarZone()) {
sendMessage("You can not claim a War Zone.");
return;
}
if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) { if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) {
sendMessage("You can't claim more land! You need more power!"); sendMessage("You can't claim more land! You need more power!");
return; return;
@ -49,11 +63,6 @@ public class FCommandClaim extends FBaseCommand {
return; return;
} }
if (otherFaction.isSafeZone()) {
sendMessage("You can not claim a SafeZone.");
return;
}
if (otherFaction.isNone()) { if (otherFaction.isNone()) {
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D"); myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D");
} else { //if (otherFaction.isNormal()) { } else { //if (otherFaction.isNormal()) {

View File

@ -127,8 +127,20 @@ public class FCommandHelp extends FBaseCommand {
pageLines.add("Finally some commands for the server admins:"); pageLines.add("Finally some commands for the server admins:");
pageLines.add( new FCommandVersion().getUseageTemplate() ); pageLines.add( new FCommandVersion().getUseageTemplate() );
pageLines.add( new FCommandSafeclaim().getUseageTemplate() ); pageLines.add( new FCommandSafeclaim().getUseageTemplate() );
pageLines.add( new FCommandSafeunclaimall().getUseageTemplate() );
pageLines.add( new FCommandWarclaim().getUseageTemplate() );
pageLines.add( new FCommandWarunclaimall().getUseageTemplate() );
pageLines.add( new FCommandWorldNoClaim().getUseageTemplate() );
pageLines.add( new FCommandWorldNoPowerLoss().getUseageTemplate() );
pageLines.add( new FCommandBypass().getUseageTemplate() ); pageLines.add( new FCommandBypass().getUseageTemplate() );
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>();
pageLines.add("More commands for server admins:");
pageLines.add( new FCommandLock().getUseageTemplate() );
pageLines.add( new FCommandReload().getUseageTemplate() );
pageLines.add( new FCommandSaveAll().getUseageTemplate() );
helpPages.add(pageLines);
} }
} }

View File

@ -1,7 +1,14 @@
package org.mcteam.factions.commands; package org.mcteam.factions.commands;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.mcteam.factions.Board;
import org.mcteam.factions.Conf; import org.mcteam.factions.Conf;
import org.mcteam.factions.Faction; import org.mcteam.factions.Faction;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.FPlayer;
import org.mcteam.factions.struct.Relation;
import org.mcteam.factions.struct.Role; import org.mcteam.factions.struct.Role;
public class FCommandHome extends FBaseCommand { public class FCommandHome extends FBaseCommand {
@ -30,6 +37,38 @@ public class FCommandHome extends FBaseCommand {
return; return;
} }
Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if (Conf.homesTeleportAllowedEnemyDistance > 0 && ! faction.isSafeZone() && ! me.isInOwnTerritory()) {
Location loc = player.getLocation();
World w = loc.getWorld();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
for (Player p : player.getServer().getOnlinePlayers())
{
if (p == null || !p.isOnline() || p.isDead() || p == player || p.getWorld() != w)
continue;
FPlayer fp = FPlayer.get(p);
if (me.getRelation(fp) != Relation.ENEMY)
continue;
Location l = p.getLocation();
int dx = Math.abs(x - l.getBlockX());
int dy = Math.abs(y - l.getBlockY());
int dz = Math.abs(z - l.getBlockZ());
int delta = dx + dy + dz;
if (delta > Conf.homesTeleportAllowedEnemyDistance)
continue;
me.sendMessage("You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");
return;
}
}
player.teleport(myFaction.getHome()); player.teleport(myFaction.getHome());
} }

View File

@ -30,6 +30,7 @@ public class FCommandList extends FBaseCommand {
ArrayList<Faction> FactionList = new ArrayList<Faction>(Faction.getAll()); ArrayList<Faction> FactionList = new ArrayList<Faction>(Faction.getAll());
FactionList.remove(Faction.getNone()); FactionList.remove(Faction.getNone());
FactionList.remove(Faction.getSafeZone()); FactionList.remove(Faction.getSafeZone());
FactionList.remove(Faction.getWarZone());
int page = 1; int page = 1;
if (parameters.size() > 0) { if (parameters.size() > 0) {

View File

@ -0,0 +1,34 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Board;
import org.mcteam.factions.Faction;
import org.mcteam.factions.Factions;
public class FCommandSafeunclaimall extends FBaseCommand {
public FCommandSafeunclaimall() {
aliases.add("safeunclaimall");
aliases.add("safedeclaimall");
helpDescription = "Unclaim all safezone land";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermManageSafeZone(sender);
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
Board.unclaimAll(Faction.getSafeZone().getId());
sendMessage("You unclaimed ALL safe zone land.");
}
}

View File

@ -35,6 +35,23 @@ public class FCommandUnclaim extends FBaseCommand {
} }
return; return;
} }
else if (otherFaction.isWarZone()) {
if (Factions.hasPermManageWarZone(sender)) {
Board.removeAt(flocation);
sendMessage("War zone was unclaimed.");
} else {
sendMessage("This is a war zone. You lack permissions to unclaim.");
}
return;
}
if (Conf.adminBypassPlayers.contains(player.getName())) {
Board.removeAt(flocation);
otherFaction.sendMessage(me.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land.");
sendMessage("You unclaimed this land.");
return;
}
if ( ! assertHasFaction()) { if ( ! assertHasFaction()) {
return; return;

View File

@ -0,0 +1,54 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Board;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.Faction;
import org.mcteam.factions.Factions;
public class FCommandWarclaim extends FBaseCommand {
public FCommandWarclaim() {
aliases.add("warclaim");
aliases.add("war");
optionalParameters.add("radius");
helpDescription = "Claim land for the warzone";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermManageWarZone(sender);
}
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
// The current location of the player
FLocation playerFlocation = new FLocation(me);
// Was a radius set?
if (parameters.size() > 0) {
int radius = Integer.parseInt(parameters.get(0));
FLocation from = playerFlocation.getRelative(radius, radius);
FLocation to = playerFlocation.getRelative(-radius, -radius);
for (FLocation locToClaim : FLocation.getArea(from, to)) {
Board.setFactionAt(Faction.getWarZone(), locToClaim);
}
sendMessage("You claimed "+(1+radius*2)*(1+radius*2)+" chunks for the war zone.");
} else {
Board.setFactionAt(Faction.getWarZone(), playerFlocation);
sendMessage("This land is now a war zone");
}
}
}

View File

@ -0,0 +1,34 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Board;
import org.mcteam.factions.Faction;
import org.mcteam.factions.Factions;
public class FCommandWarunclaimall extends FBaseCommand {
public FCommandWarunclaimall() {
aliases.add("warunclaimall");
aliases.add("wardeclaimall");
helpDescription = "Unclaim all warzone land";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermManageWarZone(sender);
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
Board.unclaimAll(Faction.getWarZone().getId());
sendMessage("You unclaimed ALL war zone land.");
}
}

View File

@ -0,0 +1,39 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Conf;
import org.mcteam.factions.Factions;
public class FCommandWorldNoClaim extends FBaseCommand {
public FCommandWorldNoClaim() {
aliases.add("worldnoclaim");
helpDescription = "Disable claims in this world";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermWorlds(sender);
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
String worldName = me.getPlayer().getWorld().getName();
if ( ! Conf.worldsNoClaiming.contains(worldName)) {
Conf.worldsNoClaiming.add(worldName);
me.sendMessage("Faction land claiming is now DISALLOWED in this world (\"" + worldName + "\").");
} else {
Conf.worldsNoClaiming.remove(worldName);
me.sendMessage("Faction land claiming is now ALLOWED in this world (\"" + worldName + "\").");
}
}
}

View File

@ -0,0 +1,39 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Conf;
import org.mcteam.factions.Factions;
public class FCommandWorldNoPowerLoss extends FBaseCommand {
public FCommandWorldNoPowerLoss() {
aliases.add("worldnopowerloss");
helpDescription = "Disable power loss in this world";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermWorlds(sender);
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
String worldName = me.getPlayer().getWorld().getName();
if ( ! Conf.worldsNoPowerLoss.contains(worldName)) {
Conf.worldsNoPowerLoss.add(worldName);
me.sendMessage("Power loss from death is now DISABLED in this world (\"" + worldName + "\").");
} else {
Conf.worldsNoPowerLoss.remove(worldName);
me.sendMessage("Power loss from death is now ENABLED in this world (\"" + worldName + "\").");
}
}
}

View File

@ -73,6 +73,13 @@ public class FactionsBlockListener extends BlockListener {
me.sendMessage("You can't "+action+" in a safe zone."); me.sendMessage("You can't "+action+" in a safe zone.");
return false; return false;
} }
else if (otherFaction.isWarZone()) {
if (Factions.hasPermManageWarZone(player) || !Conf.warZoneDenyBuild) {
return true;
}
me.sendMessage("You can't "+action+" in a war zone.");
return false;
}
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();

View File

@ -39,6 +39,19 @@ public class FactionsEntityListener extends EntityListener {
Player player = (Player) entity; Player player = (Player) entity;
FPlayer fplayer = FPlayer.get(player); FPlayer fplayer = FPlayer.get(player);
Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
if (faction.isWarZone()) { // war zones always override worldsNoPowerLoss either way, thus this layout
if (! Conf.warZonePowerLoss) {
fplayer.sendMessage("You didn't lose any power since you were in a war zone.");
return;
}
if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
fplayer.sendMessage("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.");
}
} else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
fplayer.sendMessage("You didn't lose any power due to the world you died in.");
return;
}
fplayer.onDeath(); fplayer.onDeath();
fplayer.sendMessage("Your power is now "+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded()); fplayer.sendMessage("Your power is now "+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded());
} }
@ -83,14 +96,26 @@ public class FactionsEntityListener extends EntityListener {
return; return;
} }
if ((Conf.territoryBlockCreepers || faction.isSafeZone()) && event.getEntity() instanceof Creeper) { if (event.getEntity() instanceof Creeper && (
// creeper which might need prevention, if inside faction territory (faction.isNormal() && Conf.territoryBlockCreepers) ||
(faction.isWarZone() && Conf.warZoneBlockCreepers) ||
faction.isSafeZone()
)) {
// creeper which needs prevention
event.setCancelled(true); event.setCancelled(true);
} else if ((Conf.territoryBlockFireballs || faction.isSafeZone()) && event.getEntity() instanceof Fireball) { } else if (event.getEntity() instanceof Fireball && (
// ghast fireball which might need prevention, if inside faction territory (faction.isNormal() && Conf.territoryBlockFireballs) ||
(faction.isWarZone() && Conf.warZoneBlockFireballs) ||
faction.isSafeZone()
)) {
// ghast fireball which needs prevention
event.setCancelled(true); event.setCancelled(true);
} else if (Conf.territoryBlockTNT || (faction.isSafeZone() && Conf.safeZoneBlockTNT)) { } else if (
// we'll assume it's TNT, which might need prevention, if inside faction territory or safe zone (faction.isNormal() && Conf.territoryBlockTNT) ||
(faction.isWarZone() && Conf.warZoneBlockTNT) ||
(faction.isSafeZone() && Conf.safeZoneBlockTNT)
) {
// we'll assume it's TNT, which needs prevention
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -251,6 +276,13 @@ public class FactionsEntityListener extends EntityListener {
me.sendMessage("You can't "+action+" paintings in a safe zone."); me.sendMessage("You can't "+action+" paintings in a safe zone.");
return false; return false;
} }
else if (otherFaction.isWarZone()) {
if (Factions.hasPermManageWarZone(player) || !Conf.warZoneDenyBuild) {
return true;
}
me.sendMessage("You can't "+action+" paintings in a war zone.");
return false;
}
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();

View File

@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.mcteam.factions.Board; import org.mcteam.factions.Board;
import org.mcteam.factions.Conf; import org.mcteam.factions.Conf;
@ -109,6 +110,13 @@ public class FactionsPlayerListener extends PlayerListener{
FPlayer.autoLeaveOnInactivityRoutine(); FPlayer.autoLeaveOnInactivityRoutine();
} }
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
// Make sure player's power is up to date when they log off.
FPlayer me = FPlayer.get(event.getPlayer());
me.getPower();
}
@Override @Override
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
FPlayer me = FPlayer.get(event.getPlayer()); FPlayer me = FPlayer.get(event.getPlayer());
@ -192,6 +200,13 @@ public class FactionsPlayerListener extends PlayerListener{
me.sendMessage("You can't use "+TextUtil.getMaterialName(material)+" in a safe zone."); me.sendMessage("You can't use "+TextUtil.getMaterialName(material)+" in a safe zone.");
return false; return false;
} }
else if (otherFaction.isWarZone() && Conf.warZoneDenyUseage) {
if (Factions.hasPermManageWarZone(player)) {
return true;
}
me.sendMessage("You can't use "+TextUtil.getMaterialName(material)+" in a war zone.");
return false;
}
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();