Added unclaim and disband chest resets to LWC

This commit is contained in:
Patrick 2012-01-10 19:09:15 -05:00
parent 1d0ba04336
commit c2f0f5ad51
5 changed files with 54 additions and 5 deletions

@ -10,8 +10,8 @@ import java.util.Map.Entry;
import java.util.TreeMap;
import org.bukkit.ChatColor;
import com.google.gson.reflect.TypeToken;
import com.massivecraft.factions.integration.LWCFeatures;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.AsciiCompass;
import com.massivecraft.factions.zcore.util.DiscUtil;
@ -87,6 +87,10 @@ public class Board
Entry<FLocation, String> entry = iter.next();
if (entry.getValue().equals(factionId))
{
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
{
LWCFeatures.clearAllChests(entry.getKey());
}
iter.remove();
}
}
@ -126,6 +130,10 @@ public class Board
Entry<FLocation, String> entry = iter.next();
if ( ! Factions.i.exists(entry.getValue()))
{
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
{
LWCFeatures.clearAllChests(entry.getKey());
}
P.p.log("Board cleaner removed "+entry.getValue()+" from "+entry.getKey());
iter.remove();
}

@ -71,7 +71,10 @@ public class Conf
public static boolean worldGuardChecking = false;
//LWC
public static boolean lwcIntegration = false;
public static boolean onUnclaimResetLwcLocks = false;
public static boolean onCaptureResetLwcLocks = false;
// server logging options
public static boolean logFactionCreate = true;

@ -794,7 +794,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
if (LWCFeatures.getEnabled()&& ! forFaction.isSafeZone() && ! forFaction.isWarZone() && Board.getIdAt(flocation) != "0")
{
LWCFeatures.clearChests(location, this);
LWCFeatures.clearOtherChests(flocation, this.getFaction());
}
// announce success

@ -4,6 +4,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -11,6 +12,7 @@ import org.bukkit.entity.Player;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.LWCFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
@ -514,6 +516,11 @@ public class Faction extends Entity implements EconomyParticipator
public void clearClaimOwnership(FLocation loc)
{
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
{
LWCFeatures.clearAllChests(loc);
Bukkit.getServer().broadcastMessage("boardclearat / clearclaim");
}
claimOwnership.remove(loc);
}
@ -544,6 +551,10 @@ public class Faction extends Entity implements EconomyParticipator
if (ownerData.isEmpty())
{
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
{
LWCFeatures.clearAllChests(entry.getKey());
}
claimOwnership.remove(entry.getKey());
}
}

@ -3,6 +3,7 @@ package com.massivecraft.factions.integration;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
@ -11,8 +12,9 @@ import org.bukkit.block.BlockState;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class LWCFeatures
@ -29,8 +31,34 @@ public class LWCFeatures
P.p.log("Successfully hooked into LWC!");
}
public static void clearChests(Location location, FPlayer fPlayer)
public static void clearOtherChests(FLocation flocation, Faction faction)
{
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
Chunk chunk = location.getChunk();
BlockState[] blocks = chunk.getTileEntities();
List<Block> chests = new LinkedList<Block>();
for(int x = 0; x < blocks.length; x++)
{
if(blocks[x].getType() == Material.CHEST)
{
chests.add(blocks[x].getBlock());
}
}
for(int x = 0; x < chests.size(); x++)
{
if(lwc.findProtection(chests.get(x)) != null)
{
if(!faction.getFPlayers().contains(FPlayers.i.get(lwc.findProtection(chests.get(x)).getBukkitOwner())))
lwc.findProtection(chests.get(x)).remove();
}
}
}
public static void clearAllChests(FLocation flocation)
{
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
Chunk chunk = location.getChunk();
BlockState[] blocks = chunk.getTileEntities();
List<Block> chests = new LinkedList<Block>();
@ -47,7 +75,6 @@ public class LWCFeatures
{
if(lwc.findProtection(chests.get(x)) != null)
{
if(!fPlayer.getFaction().getFPlayers().contains(FPlayers.i.get(lwc.findProtection(chests.get(x)).getBukkitOwner())))
lwc.findProtection(chests.get(x)).remove();
}
}