Added protection to the vault where hoppers cannot be placed to use the vault as infinite storage.
This commit is contained in:
parent
c368e19e17
commit
e6559a439a
@ -145,7 +145,9 @@ public class FactionsBlockListener implements Listener {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockLoc.getBlock().getType() == Material.CHEST) {
|
||||
Material blockMaterial = blockLoc.getBlock().getType();
|
||||
|
||||
if (blockMaterial == Material.CHEST || (P.p.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
|
||||
return;
|
||||
@ -161,6 +163,45 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHopperPlace(BlockPlaceEvent e) {
|
||||
|
||||
if (e.getItemInHand().getType() != Material.HOPPER && !P.p.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
||||
|
||||
if (factionAt.isWilderness() || factionAt.getVault() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
|
||||
Block start = e.getBlockPlaced();
|
||||
int radius = 1;
|
||||
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) {
|
||||
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++) {
|
||||
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++) {
|
||||
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
|
||||
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockLoc.getBlock().getType() == Material.CHEST) {
|
||||
if (factionAt.getVault().equals(blockLoc)) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
// if not a sticky piston, retraction should be fine
|
||||
|
@ -580,10 +580,11 @@ public enum TL {
|
||||
COMMAND_VAULT_DESCRIPTION("Open your placed faction vault!"),
|
||||
COMMAND_VAULT_INVALID("&c&l[!]&7 Your vault was either&c claimed&7, &cbroken&7, or has&c not been&7 placed yet."),
|
||||
COMMAND_VAULT_OPENING("&c&l[!]&7 Opening faction vault."),
|
||||
COMMAND_VAULT_NO_HOPPER("&c&l[!] &7You cannot place a hopper near a vault!"),
|
||||
|
||||
COMMAND_GETVAULT_ALREADYSET("&c&l[!]&7 Vault has already been set!"),
|
||||
COMMAND_GETVAULT_ALREADYHAVE("&c&l[!]&7 You already have a vault in your inventory!"),
|
||||
COMMAND_GETVAULT_CHESTNEAR("&c&l[!]&7 &7There is a chest &cnearby"),
|
||||
COMMAND_GETVAULT_CHESTNEAR("&c&l[!]&7 &7There is a chest or hopper &cnearby"),
|
||||
COMMAND_GETVAULT_SUCCESS("&cSucessfully set vault."),
|
||||
COMMAND_GETVAULT_INVALIDLOCATION("&cVault can only be placed in faction land!"),
|
||||
COMMAND_GETVAULT_DESCRIPTION("Get the faction vault item!"),
|
||||
|
@ -721,6 +721,7 @@ fnear:
|
||||
# +------------------------------------------------------+ #
|
||||
fvault:
|
||||
Enabled: true
|
||||
No-Hoppers-near-vault: true
|
||||
Price: 5000
|
||||
Item:
|
||||
Name: '&e&l*&f&l*&e&l* &e&lFaction Vault &7(Place) &e&l*&f&l*&e&l*'
|
||||
|
Loading…
Reference in New Issue
Block a user