LogBlock ChestAccess logging Support

This commit is contained in:
Sn0wStorm
2014-04-09 00:35:08 +02:00
parent 1c6fe6cc33
commit 13abf2475c
9 changed files with 180 additions and 18 deletions
+24 -3
View File
@@ -16,6 +16,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.Plugin;
import com.dre.brewery.integration.LWCBarrel;
import com.dre.brewery.integration.LogBlockBarrel;
import com.dre.brewery.integration.WGBarrel;
import org.apache.commons.lang.ArrayUtils;
@@ -74,7 +75,7 @@ public class Barrel {
if (woodsloc == null && stairsloc == null) {
Block broken = getBrokenBlock(true);
if (broken != null) {
remove(broken);
remove(broken, null);
return;
}
}
@@ -89,7 +90,8 @@ public class Barrel {
broken = barrel.getBrokenBlock(false);
if (broken != null) {
// remove the barrel if it was destroyed
barrel.remove(broken);
barrel.willDestroy();
barrel.remove(broken, null);
continue;
} else {
// Dont check this barrel again, its enough to check it once after every restart
@@ -131,7 +133,12 @@ public class Barrel {
return true;
}
// Ask for permission to destroy barrel, remove protection if has
public boolean hasPermsDestroy(Player player) {
if (player == null) {
willDestroy();
return true;
}
if (P.p.hasLWC) {
return LWCBarrel.checkDestroy(player, this);
}
@@ -139,6 +146,13 @@ public class Barrel {
return true;
}
// If something other than the Player is destroying the barrel, inform protection plugins
public void willDestroy() {
if (P.p.hasLWC) {
LWCBarrel.remove(this);
}
}
// player opens the barrel
@SuppressWarnings("deprecation")
public void open(Player player) {
@@ -173,6 +187,10 @@ public class Barrel {
}
// reset barreltime, potions have new age
time = 0;
if (P.p.hasLB) {
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
}
player.openInventory(inventory);
}
@@ -339,12 +357,15 @@ public class Barrel {
}
// removes a barrel, throwing included potions to the ground
public void remove(Block broken) {
public void remove(Block broken, Player breaker) {
if (inventory != null) {
for (HumanEntity human : inventory.getViewers()) {
human.closeInventory();
}
ItemStack[] items = inventory.getContents();
if (P.p.hasLB && breaker != null) {
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
}
for (ItemStack item : items) {
if (item != null) {
Brew brew = Brew.get(item);