Skip to content

Commit

Permalink
Gracefully handle failure to spawn mobs due to WorldGuard.
Browse files Browse the repository at this point in the history
  • Loading branch information
totemo committed Apr 3, 2020
1 parent f2755d9 commit 512539f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/nu/nerd/beastmaster/commands/BeastMobExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,17 @@ protected boolean onCommandSpawnOrStatue(CommandSender sender, String[] args) {

boolean isStatue = args[0].equals("statue");
LivingEntity mob = BeastMaster.PLUGIN.spawnMob(spawnLoc, mobType, false);
mob.setAI(!isStatue);
sender.sendMessage(ChatColor.GOLD + "Spawned " + ChatColor.YELLOW + mobType.getId() +
ChatColor.GOLD + (isStatue ? " statue" : "") + " at " +
ChatColor.YELLOW + Util.formatLocation(spawnLoc) +
ChatColor.GOLD + ".");
if (mob != null) {
mob.setAI(!isStatue);
sender.sendMessage(ChatColor.GOLD + "Spawned " + ChatColor.YELLOW + mobType.getId() +
ChatColor.GOLD + (isStatue ? " statue" : "") + " at " +
ChatColor.YELLOW + Util.formatLocation(spawnLoc) +
ChatColor.GOLD + ".");
} else {
sender.sendMessage(ChatColor.RED + "Unable to spawn a " + mobType.getId() +
(isStatue ? " statue" : "") + " at " + Util.formatLocation(spawnLoc) + ".");
sender.sendMessage(ChatColor.RED + "Is there a WorldGuard region preventing that?");
}
return true;
} // onCommandSpawnOrStatue

Expand Down

0 comments on commit 512539f

Please sign in to comment.