Updates in preparation for 1.1.7 release:

* /f map has been updated to fit inside the new Bukkit line-width limits (39 tiles wide instead of 49)
* Players who aren't currently in a faction should no longer get "Person left your faction" messages when others join a faction
* Attempt at simple workaround for error related to NPCs from Citizens plugin
* Placement and removal of paintings is now prevented if you're in another faction's territory
This commit is contained in:
Brettflan 2011-04-28 15:45:43 -05:00
parent 8a4463b599
commit a02fcca54d
4 changed files with 82 additions and 6 deletions

View File

@ -64,7 +64,7 @@ public class Conf {
public static transient Set<CreatureType> safeZoneNerfedCreatureTypes = new HashSet<CreatureType>();
public static transient int mapHeight = 8;
public static transient int mapWidth = 49;
public static transient int mapWidth = 39;
static {
territoryProtectedMaterials.add(Material.WOODEN_DOOR);

View File

@ -370,11 +370,14 @@ public class FPlayer {
sendMessage("You must give the admin role to someone else first.");
return;
}
myFaction.sendMessage(this.getNameAndRelevant(myFaction) + Conf.colorSystem + " left your faction.");
if (myFaction.isNormal()) {
myFaction.sendMessage(this.getNameAndRelevant(myFaction) + Conf.colorSystem + " left your faction.");
}
this.resetFactionData();
if (myFaction.getFPlayers().size() == 0) {
if (myFaction.isNormal() && myFaction.getFPlayers().size() == 0) {
// Remove this faction
for (FPlayer fplayer : FPlayer.getAllOnline()) {
fplayer.sendMessage("The faction "+myFaction.getTag(fplayer)+Conf.colorSystem+" was disbanded.");

View File

@ -151,6 +151,8 @@ public class Factions extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_TARGET, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PAINTING_BREAK, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PAINTING_PLACE, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Event.Priority.Normal, this);

View File

@ -15,8 +15,12 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
import org.bukkit.event.painting.PaintingBreakEvent;
import org.bukkit.event.painting.PaintingPlaceEvent;
import org.mcteam.factions.Board;
import org.mcteam.factions.Conf;
import org.mcteam.factions.Factions;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.FPlayer;
import org.mcteam.factions.Faction;
@ -96,7 +100,7 @@ public class FactionsEntityListener extends EntityListener {
Entity damagee = sub.getEntity();
int damage = sub.getDamage();
if ( ! (damagee instanceof Player)) {
if ( ! (damagee instanceof Player) || damagee.getLocation() == null) {
return true;
}
@ -182,4 +186,71 @@ public class FactionsEntityListener extends EntityListener {
event.setCancelled(true);
}
}
@Override
public void onPaintingBreak(PaintingBreakEvent event)
{
if (event.isCancelled()) {
return;
}
if (! (event instanceof PaintingBreakByEntityEvent)) {
return;
}
Entity breaker = ((PaintingBreakByEntityEvent)event).getRemover();
if (! (breaker instanceof Player)) {
return;
}
FLocation loc = new FLocation(event.getPainting().getLocation());
if ( ! this.playerCanDoPaintings((Player)breaker, loc, "remove")) {
event.setCancelled(true);
}
}
@Override
public void onPaintingPlace(PaintingPlaceEvent event)
{
if (event.isCancelled()) {
return;
}
if ( ! this.playerCanDoPaintings(event.getPlayer(), new FLocation(event.getBlock()), "place")) {
event.setCancelled(true);
}
}
public boolean playerCanDoPaintings(Player player, FLocation loc, String action) {
if (Conf.adminBypassPlayers.contains(player.getName())) {
return true;
}
Faction otherFaction = Board.getFactionAt(loc);
if (otherFaction.isNone()) {
return true;
}
FPlayer me = FPlayer.get(player);
if (otherFaction.isSafeZone()) {
if (Factions.hasPermManageSafeZone(player) || !Conf.safeZoneDenyBuild) {
return true;
}
me.sendMessage("You can't "+action+" paintings in a safe zone.");
return false;
}
Faction myFaction = me.getFaction();
// Cancel if we are not in our own territory
if (myFaction != otherFaction) {
me.sendMessage("You can't "+action+" paintings in the territory of "+otherFaction.getTag(myFaction));
return false;
}
return true;
}
}