use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard method onBlockRedstone.
/**
* Stop redstone if team members are offline and disableOfflineRedstone is TRUE.
* @param e - event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e) {
if (Settings.disableOfflineRedstone) {
// Check world
if (!inWorld(e.getBlock())) {
return;
}
// Check if this is on an island
Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation());
if (island == null || island.isSpawn()) {
return;
}
for (UUID member : island.getMembers()) {
if (plugin.getServer().getPlayer(member) != null)
return;
}
e.setNewCurrent(0);
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_8 method placeArmorStandEvent.
// Armor stand events
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
void placeArmorStandEvent(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (DEBUG) {
plugin.getLogger().info("1.8 " + "Armor stand place " + e.getEventName());
}
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.ARMOR_STAND)) {
// 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.8 " + "DEBUG: armor stand place check");
if (Settings.limitedBlocks.containsKey("ARMOR_STAND") && Settings.limitedBlocks.get("ARMOR_STAND") > -1) {
// plugin.getLogger().info("1.8 " + "DEBUG: count armor stands");
int count = island.getTileEntityCount(Material.ARMOR_STAND, e.getPlayer().getWorld());
// plugin.getLogger().info("1.8 " + "DEBUG: count is " + count + " limit is " + Settings.limitedBlocks.get("ARMOR_STAND"));
if (Settings.limitedBlocks.get("ARMOR_STAND") <= count) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(Material.ARMOR_STAND.toString()))).replace("[number]", String.valueOf(Settings.limitedBlocks.get("ARMOR_STAND"))));
e.setCancelled(true);
return;
}
}
return;
}
// plugin.getLogger().info("1.8 " + "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 onLingeringPotionDamage.
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
return;
}
if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
return;
}
if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
// Self damage
if (attacker.equals(e.getEntity().getUniqueId())) {
return;
}
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
boolean inNether = false;
if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) {
inNether = true;
}
// Monsters being hurt
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
// Normal island check
if (island != null && island.getMembers().contains(attacker)) {
// Members always allowed
return;
}
if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
return;
}
// Not allowed
e.setCancelled(true);
return;
}
// Mobs being hurt
if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) {
if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) {
return;
}
e.setCancelled(true);
return;
}
// Establish whether PVP is allowed or not.
boolean pvp = false;
if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) {
pvp = true;
}
// Players being hurt PvP
if (e.getEntity() instanceof Player) {
if (pvp) {
return;
} else {
e.setCancelled(true);
return;
}
}
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandGuard1_9 method onBlockForm.
/**
* Handles Frost Walking on visitor's islands
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockForm(EntityBlockFormEvent e) {
if (e.getEntity() instanceof Player && e.getNewState().getType().equals(Material.FROSTED_ICE)) {
Player player = (Player) e.getEntity();
if (!IslandGuard.inWorld(player)) {
return;
}
if (player.isOp()) {
return;
}
// This permission bypasses protection
if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// Check island
Island island = plugin.getGrid().getIslandAt(player.getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
return;
}
if (island != null) {
if (island.getMembers().contains(player.getUniqueId()) || island.getIgsFlag(SettingsFlag.PLACE_BLOCKS)) {
return;
}
}
// Silently cancel the event
e.setCancelled(true);
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class JoinLeaveEvents method onPlayerJoin.
/**
* @param event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
if (DEBUG)
plugin.getLogger().info("DEBUG: on PlayerJoin");
final Player player = event.getPlayer();
final UUID playerUUID = player.getUniqueId();
if (DEBUG)
plugin.getLogger().info("DEBUG: got player UUID");
if (playerUUID == null) {
plugin.getLogger().severe("Player " + player.getName() + " has a null UUID!");
return;
}
// Check language permission
if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) {
if (DEBUG)
plugin.getLogger().info("DEBUG: checking language");
// Get language
String language = getLanguage(player);
// Check if we have this language
if (plugin.getResource("locale/" + language + ".yml") != null) {
if (DEBUG)
plugin.getLogger().info("DEBUG:check if lang exists");
if (plugin.getPlayers().getLocale(playerUUID).isEmpty()) {
if (DEBUG)
plugin.getLogger().info("DEBUG: setting locale to " + language);
plugin.getPlayers().setLocale(playerUUID, language);
}
}
} else {
// Default locale
if (DEBUG)
plugin.getLogger().info("DEBUG: using default locale");
plugin.getPlayers().setLocale(playerUUID, "");
}
// Check updates
if (player.isOp() && plugin.getUpdateCheck() != null) {
if (DEBUG)
plugin.getLogger().info("DEBUG: checking Updates");
plugin.checkUpdatesNotify(player);
}
if (players == null) {
plugin.getLogger().severe("players is NULL");
return;
}
// If this player is not an island player just skip all this
if (DEBUG)
plugin.getLogger().info("DEBUG: checking if player has island or is in team");
if (!players.hasIsland(playerUUID) && !players.inTeam(playerUUID)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: not in team and does not have island");
return;
}
if (DEBUG)
plugin.getLogger().info("DEBUG: has island");
UUID leader = null;
Location loc = null;
/*
* This should not be needed
*/
if (players.inTeam(playerUUID) && players.getTeamIslandLocation(playerUUID) == null) {
if (DEBUG)
plugin.getLogger().info("DEBUG: reseting team island");
leader = players.getTeamLeader(playerUUID);
players.setTeamIslandLocation(playerUUID, players.getIslandLocation(leader));
}
// Only happens when the team leader logs in
if (players.inTeam(playerUUID) && players.getTeamLeader(playerUUID).equals(playerUUID)) {
// Run through this team leader's players and check they are correct
Iterator<UUID> it = players.getMembers(playerUUID).iterator();
while (it.hasNext()) {
UUID member = it.next();
if (players.getTeamLeader(member) != null && !players.getTeamLeader(member).equals(playerUUID)) {
plugin.getLogger().warning(plugin.getPlayers().getName(member) + " is on more than one team. Fixing...");
plugin.getLogger().warning("Removing " + player.getName() + " as team leader, keeping " + plugin.getPlayers().getName(players.getTeamLeader(member)));
players.removeMember(players.getTeamLeader(member), member);
}
}
}
// Leader or solo
if (DEBUG)
plugin.getLogger().info("DEBUG: Getting island info");
if (players.hasIsland(playerUUID)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: owner");
loc = players.getIslandLocation(playerUUID);
leader = playerUUID;
} else if (players.inTeam(playerUUID)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: team");
// Team player
loc = players.getTeamIslandLocation(playerUUID);
leader = players.getTeamLeader(playerUUID);
if (leader == null) {
plugin.getLogger().severe("Player " + player.getName() + " is in a team but leader's UUID is missing. Leaving team.");
players.setLeaveTeam(playerUUID);
}
}
// If the player has an island location of some kind
if (loc != null && leader != null) {
if (DEBUG)
plugin.getLogger().info("DEBUG: getting island");
// Check if the island location is on the grid
Island island = plugin.getGrid().getIslandAt(loc);
if (island == null) {
if (DEBUG)
plugin.getLogger().info("DEBUG: getIslandLoc is null!");
// Island isn't in the grid, so add it
// See if this owner is tagged as having an island elsewhere
Island islandByOwner = plugin.getGrid().getIsland(leader);
if (islandByOwner == null) {
// No previous ownership, so just create the new island in the grid
if (plugin.getGrid().onGrid(loc)) {
plugin.getGrid().addIsland(loc.getBlockX(), loc.getBlockZ(), leader);
} else {
plugin.getLogger().severe(player.getName() + " joined and has an island at " + loc + " but those coords are NOT on the grid! Use admin register commands to correct!");
}
} else {
// We have a mismatch - correct in favor of the player info
if (DEBUG)
plugin.getLogger().info("DEBUG: getIslandLoc is null but there is a player listing");
plugin.getLogger().warning(player.getName() + " login: mismatch - player.yml and islands.yml are out of sync. Fixing...");
// Cannot delete by location
plugin.getGrid().deleteIslandOwner(playerUUID);
if (plugin.getGrid().onGrid(loc)) {
plugin.getGrid().addIsland(loc.getBlockX(), loc.getBlockZ(), leader);
} else {
plugin.getLogger().severe(player.getName() + " joined and has an island at " + loc + " but those coords are NOT on the grid! Use admin register commands to correct!");
}
}
} else {
if (DEBUG)
plugin.getLogger().info("DEBUG: island is not null");
// Island at this location exists
// plugin.getLogger().info("DEBUG: getIslandLoc is not null - island exists");
// See if this owner is tagged as having an island elsewhere
Island islandByOwner = plugin.getGrid().getIsland(leader);
if (islandByOwner == null) {
plugin.getLogger().warning(player.getName() + " login: has island, but islands.yml says it is unowned, correcting...");
// No previous ownership, so just assign ownership
plugin.getGrid().setIslandOwner(island, leader);
} else {
if (DEBUG)
plugin.getLogger().info("DEBUG: island by owner found");
if (!islandByOwner.equals(island)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: mismatch");
plugin.getLogger().warning(player.getName() + " login: mismatch - islands.yml and player.yml are out of sync. Fixing...");
// We have a mismatch - correct in favor of the player info
plugin.getGrid().deleteIsland(islandByOwner.getCenter());
plugin.getGrid().setIslandOwner(island, leader);
} else {
if (island.getOwner().equals(player.getUniqueId())) {
if (DEBUG) {
plugin.getLogger().info("DEBUG: This player owns the island and island protection size is " + islandByOwner.getProtectionSize());
plugin.getLogger().info("DEBUG: everything looks good");
}
// Dynamic island range sizes with permissions
boolean hasARangePerm = false;
int range = Settings.islandProtectionRange;
// Check for zero protection range
if (island.getProtectionSize() == 0) {
plugin.getLogger().warning("Player " + player.getName() + "'s island had a protection range of 0. Setting to default " + range);
island.setProtectionSize(range);
}
for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.range.")) {
if (DEBUG)
plugin.getLogger().info("DEBUG: perm found");
if (perms.getPermission().contains(Settings.PERMPREFIX + "island.range.*")) {
// Ignore
break;
} else {
String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.range.");
if (spl.length > 1) {
if (!NumberUtils.isDigits(spl[1])) {
plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
} else {
if (DEBUG)
plugin.getLogger().info("DEBUG: found number perm");
hasARangePerm = true;
range = Math.max(range, Integer.valueOf(spl[1]));
if (DEBUG)
plugin.getLogger().info("DEBUG: highest range is " + range);
}
}
}
}
}
// Only set the island range if the player has a perm to override the default
if (hasARangePerm) {
// Do some sanity checking
if (range % 2 != 0) {
range--;
if (DEBUG)
plugin.getLogger().warning("Login range setting: Protection range must be even, using " + range + " for " + player.getName());
}
if (DEBUG)
plugin.getLogger().info("DEBUG: final range is " + range + " island protection size = " + islandByOwner.getProtectionSize());
// Range can go up or down
if (range != islandByOwner.getProtectionSize()) {
plugin.getMessages().storeMessage(playerUUID, plugin.myLocale(playerUUID).adminSetRangeUpdated.replace("[number]", String.valueOf(range)));
plugin.getLogger().info("Login range setting: Island protection range changed from " + islandByOwner.getProtectionSize() + " to " + range + " for " + player.getName() + " due to permission.");
}
islandByOwner.setProtectionSize(range);
}
}
}
}
}
}
// Run the level command
if (Settings.loginLevel) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Run level calc");
new LevelCalcByChunk(plugin, plugin.getGrid().getIsland(playerUUID), playerUUID, player, false);
}
// Reset resets if the admin changes it to or from unlimited
if (Settings.resetLimit < players.getResetsLeft(playerUUID) || (Settings.resetLimit >= 0 && players.getResetsLeft(playerUUID) < 0)) {
players.setResetsLeft(playerUUID, Settings.resetLimit);
}
if (DEBUG)
plugin.getLogger().info("DEBUG: Setting player's name");
// Set the player's name (it may have changed), but only if it isn't empty
if (!player.getName().isEmpty()) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Player name is " + player.getName());
players.setPlayerName(playerUUID, player.getName());
} else {
plugin.getLogger().warning("Player that just logged in has no name! " + playerUUID.toString());
}
if (DEBUG)
plugin.getLogger().info("DEBUG: Saving player");
players.save(playerUUID);
if (Settings.logInRemoveMobs) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Removing mobs");
plugin.getGrid().removeMobs(player.getLocation());
}
// Set the TEAMNAME and TEAMSUFFIX variable if required
if (Settings.setTeamName) {
if (DEBUG)
plugin.getLogger().info("DEBUG: setTeamName");
Scoreboards.getInstance().setLevel(playerUUID);
}
// Check if they logged in to a locked island and expel them or if they are banned
Island currentIsland = plugin.getGrid().getIslandAt(player.getLocation());
if (currentIsland != null && (currentIsland.isLocked() || plugin.getPlayers().isBanned(currentIsland.getOwner(), player.getUniqueId()))) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Current island is locked, or player is banned");
if (!currentIsland.getMembers().contains(playerUUID) && !player.isOp() && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
if (DEBUG)
plugin.getLogger().info("DEBUG: No bypass - teleporting");
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).lockIslandLocked);
plugin.getGrid().homeTeleport(player);
}
}
if (DEBUG)
plugin.getLogger().info("DEBUG: Setting the player's level in chat listener");
// Set the player's level
plugin.getChatListener().setPlayerLevel(playerUUID, plugin.getPlayers().getIslandLevel(player.getUniqueId()));
if (DEBUG)
plugin.getLogger().info("DEBUG: Remove from top ten if excluded");
// Remove from TopTen if the player has the permission
if (!player.hasPermission(Settings.PERMPREFIX + "intopten")) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Removing from top ten");
TopTen.topTenRemoveEntry(playerUUID);
}
// Load any messages for the player
if (DEBUG)
plugin.getLogger().info("DEBUG: checking messages for " + player.getName());
final List<String> messages = plugin.getMessages().getMessages(playerUUID);
if (messages != null) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Messages waiting!");
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
Util.sendMessage(player, ChatColor.AQUA + plugin.myLocale(playerUUID).newsHeadline);
int i = 1;
for (String message : messages) {
Util.sendMessage(player, i++ + ": " + message);
}
// Clear the messages
plugin.getMessages().clearMessages(playerUUID);
}
}, 40L);
}
// }
if (DEBUG)
plugin.getLogger().info("DEBUG: Log in completed, passing to other plugins.");
}
Aggregations