use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_9 method onHitEndCrystal.
/**
* Handle interaction with end crystals 1.9
*
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onHitEndCrystal(final PlayerInteractAtEntityEvent e) {
if (!IslandGuard.inWorld(e.getPlayer())) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection
if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) {
// Check island
Island island = plugin.getGrid().getIslandAt(e.getRightClicked().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island != null) {
if (island.getMembers().contains(e.getPlayer().getUniqueId()) || island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_9 method onRodDamage.
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onRodDamage(final PlayerFishEvent e) {
if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (!IslandGuard.inWorld(e.getPlayer().getLocation())) {
return;
}
Player p = e.getPlayer();
if (e.getCaught() != null && (e.getCaught().getType().equals(EntityType.ARMOR_STAND) || e.getCaught().getType().equals(EntityType.ENDER_CRYSTAL))) {
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// Check if on island
if (plugin.getGrid().playerIsOnIsland(p)) {
return;
}
// Check island
Island island = plugin.getGrid().getIslandAt(e.getCaught().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.getHook().remove();
e.setCancelled(true);
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_9 method placeEndCrystalEvent.
// End crystal
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
void placeEndCrystalEvent(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (!IslandGuard.inWorld(p)) {
return;
}
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
// You can do anything if you are Op
return;
}
// Check if they are holding armor stand
for (ItemStack inHand : Util.getPlayerInHandItems(e.getPlayer())) {
if (inHand.getType().equals(Material.END_CRYSTAL)) {
// Check island
Island island = plugin.getGrid().getIslandAt(e.getPlayer().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
return;
}
if (island != null && (island.getMembers().contains(p.getUniqueId()) || island.getIgsFlag(SettingsFlag.PLACE_BLOCKS))) {
// plugin.getLogger().info("1.9 " +"DEBUG: armor stand place check");
if (Settings.limitedBlocks.containsKey("END_CRYSTAL") && Settings.limitedBlocks.get("END_CRYSTAL") > -1) {
// plugin.getLogger().info("1.9 " +"DEBUG: count armor stands");
int count = island.getTileEntityCount(Material.END_CRYSTAL, e.getPlayer().getWorld());
// plugin.getLogger().info("1.9 " +"DEBUG: count is " + count + " limit is " + Settings.limitedBlocks.get("ARMOR_STAND"));
if (Settings.limitedBlocks.get("END_CRYSTAL") <= count) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(Material.END_CRYSTAL.toString()))).replace("[number]", String.valueOf(Settings.limitedBlocks.get("END_CRYSTAL"))));
e.setCancelled(true);
return;
}
}
return;
}
// plugin.getLogger().info("1.9 " +"DEBUG: stand place cancelled");
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
e.getPlayer().updateInventory();
}
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_9 method actionAllowed.
/**
* Checks if action is allowed for player in location for flag
* @param uuid
* @param location
* @param flag
* @return true if allowed
*/
private boolean actionAllowed(UUID uuid, Location location, SettingsFlag flag) {
Player player = plugin.getServer().getPlayer(uuid);
if (player == null) {
return actionAllowed(location, flag);
}
// This permission bypasses protection
if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
return true;
}
Island island = plugin.getGrid().getProtectedIslandAt(location);
if (island != null && (island.getIgsFlag(flag) || island.getMembers().contains(player.getUniqueId()))) {
return true;
}
if (island == null && Settings.defaultWorldSettings.get(flag)) {
return true;
}
return false;
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_9 method EndCrystalDamage.
/**
* Handle end crystal damage by visitors
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void EndCrystalDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() == null || !IslandGuard.inWorld(e.getEntity())) {
return;
}
if (!(e.getEntity() instanceof EnderCrystal)) {
return;
}
Player p = null;
if (e.getDamager() instanceof Player) {
p = (Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile) {
// Get the shooter
Projectile projectile = (Projectile) e.getDamager();
ProjectileSource shooter = projectile.getShooter();
if (shooter instanceof Player) {
p = (Player) shooter;
}
}
if (p != null) {
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// Check if on island
if (plugin.getGrid().playerIsOnIsland(p)) {
return;
}
// Check island
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
Aggregations