Fixed an NPE when destroying a Clan's Home
This commit is contained in:
parent
03764ad480
commit
1ea87b8354
|
@ -382,7 +382,7 @@ public class ClansGame extends MiniPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow Clan's Home
|
// Allow Clan's Home
|
||||||
if (event.getClickedBlock().getLocation().equals(home))
|
if (event.getClickedBlock().getLocation().distance(home) <= 2 && event.getClickedBlock().getType().equals(Material.BED_BLOCK))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -398,11 +398,19 @@ public class ClansGame extends MiniPlugin
|
||||||
// Block is not Trust Allowed
|
// Block is not Trust Allowed
|
||||||
else if (!_clans.getClanBlocks().allowInteract(event.getClickedBlock().getTypeId()) || access != ClanRelation.ALLY_TRUST)
|
else if (!_clans.getClanBlocks().allowInteract(event.getClickedBlock().getTypeId()) || access != ClanRelation.ALLY_TRUST)
|
||||||
{
|
{
|
||||||
|
Location home = event.getClickedBlock() == null ? null : _clans.getClanUtility().getClanByClanName(_clans.getClanUtility().getClaim(event.getClickedBlock().getLocation()).Owner).getHome();
|
||||||
|
|
||||||
|
// Allow Clan's Home
|
||||||
|
if (event.getClickedBlock().getLocation().distance(home) <= 2 && event.getClickedBlock().getType().equals(Material.BED_BLOCK))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Disallow
|
// Disallow
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + "." + mimic));
|
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + "'s Territory." + mimic));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -419,7 +427,7 @@ public class ClansGame extends MiniPlugin
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(), player) + "." + mimic));
|
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(), player) + "'s Territory." + mimic));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -635,7 +643,7 @@ public class ClansGame extends MiniPlugin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UtilMath.offset(block.getLocation(), blockClan.getHome()) > 3)
|
if (UtilMath.offset(block.getLocation(), blockClan.getHome()) > 2)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -647,14 +655,14 @@ public class ClansGame extends MiniPlugin
|
||||||
|
|
||||||
if (!blockClan.equals(userClan))
|
if (!blockClan.equals(userClan))
|
||||||
{
|
{
|
||||||
if (blockClan.isAlly(userClan))
|
if (userClan != null && blockClan.isAlly(userClan))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main("Clans", "You cannot remove an Ally's Clan Home."));
|
UtilPlayer.message(player, F.main("Clans", "You cannot remove an Ally's Clan Home."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main("Clans", "You have destroyed " + F.elem(blockClan.getName()) + "'s Clan Home!"));
|
UtilPlayer.message(player, F.main("Clans", "You have destroyed " + F.elem(blockClan.getName()) + "'s Clan Home!"));
|
||||||
removeHome(userClan);
|
removeHome(blockClan, blockClan.getHome());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -664,7 +672,7 @@ public class ClansGame extends MiniPlugin
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
removeHome(userClan);
|
removeHome(blockClan, blockClan.getHome());
|
||||||
|
|
||||||
UtilPlayer.message(player, F.main("Clans", "You have removed your Clan Home."));
|
UtilPlayer.message(player, F.main("Clans", "You have removed your Clan Home."));
|
||||||
}
|
}
|
||||||
|
@ -675,15 +683,15 @@ public class ClansGame extends MiniPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeHome(ClanInfo clan)
|
private void removeHome(ClanInfo clan, Location clanHome)
|
||||||
{
|
{
|
||||||
clan.getHome().getBlock().setType(Material.AIR);
|
clanHome.getBlock().setType(Material.AIR);
|
||||||
|
|
||||||
for (int x2 = -1; x2 < 1; x2++)
|
for (int x2 = -1; x2 < 1; x2++)
|
||||||
{
|
{
|
||||||
for (int z2 = -1; z2 < 1; z2++)
|
for (int z2 = -1; z2 < 1; z2++)
|
||||||
{
|
{
|
||||||
Block block = clan.getHome().clone().add(x2, 0, z2).getBlock();
|
Block block = clanHome.clone().add(x2, 0, z2).getBlock();
|
||||||
if (block.getType().equals(Material.BED_BLOCK))
|
if (block.getType().equals(Material.BED_BLOCK))
|
||||||
{
|
{
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
|
|
|
@ -829,7 +829,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||||
|
|
||||||
Location home = clan.getHome();
|
Location home = clan.getHome();
|
||||||
|
|
||||||
if (!(home.getBlock().getType().equals(Material.BED) && home.add(0,1,0).getBlock().getType().equals(Material.AIR)))
|
if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0,1,0).getBlock().getType().equals(Material.AIR)))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
|
UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue