use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class IslandCmd method removePlayerFromTeam.
/**
* Removes a player from a team run by teamleader
*
* @param playerUUID - the player's UUID
* @param teamLeader
* @param makeLeader - true if this is the result of switching leader
* @return true if successful, false if not
*/
public boolean removePlayerFromTeam(final UUID playerUUID, final UUID teamLeader, boolean makeLeader) {
// Remove player from the team
plugin.getPlayers().removeMember(teamLeader, playerUUID);
// If player is not the leader of their own team
if (teamLeader == null || !playerUUID.equals(teamLeader)) {
if (!plugin.getPlayers().setLeaveTeam(playerUUID)) {
return false;
}
// plugin.getPlayers().setHomeLocation(player, null);
plugin.getPlayers().clearHomeLocations(playerUUID);
plugin.getPlayers().setIslandLocation(playerUUID, null);
plugin.getPlayers().setTeamIslandLocation(playerUUID, null);
if (!makeLeader) {
OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(playerUUID);
if (offlinePlayer.isOnline()) {
// Check perms
if (!((Player) offlinePlayer).hasPermission(Settings.PERMPREFIX + "command.leaveexempt")) {
runCommands(Settings.leaveCommands, offlinePlayer);
}
} else {
// If offline, all commands are run, sorry
runCommands(Settings.leaveCommands, offlinePlayer);
}
// Deduct a reset
if (Settings.leaversLoseReset && Settings.resetLimit >= 0) {
int resetsLeft = plugin.getPlayers().getResetsLeft(playerUUID);
if (resetsLeft > 0) {
resetsLeft--;
plugin.getPlayers().setResetsLeft(playerUUID, resetsLeft);
}
}
}
// Fire event
if (teamLeader != null) {
final Island island = plugin.getGrid().getIsland(teamLeader);
final IslandLeaveEvent event = new IslandLeaveEvent(playerUUID, island);
plugin.getServer().getPluginManager().callEvent(event);
}
} else {
// removed
if (!plugin.getPlayers().setLeaveTeam(playerUUID)) {
// Event was cancelled for some reason
return false;
}
}
return true;
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class AcidEffect method isSafeFromAcid.
/**
* Check if player can be burned by acid
* @param player
* @return true if player is not safe
*/
private boolean isSafeFromAcid(Player player) {
if (DEBUG)
plugin.getLogger().info("DEBUG: safe from acid");
if (!player.getWorld().equals(ASkyBlock.getIslandWorld())) {
if (DEBUG)
plugin.getLogger().info("DEBUG: wrong world");
return true;
}
// In liquid
Material bodyMat = player.getLocation().getBlock().getType();
Material headMat = player.getLocation().getBlock().getRelative(BlockFace.UP).getType();
if (bodyMat.equals(Material.STATIONARY_WATER))
bodyMat = Material.WATER;
if (headMat.equals(Material.STATIONARY_WATER))
headMat = Material.WATER;
if (bodyMat != Material.WATER && headMat != Material.WATER) {
if (DEBUG)
plugin.getLogger().info("DEBUG: not in water " + player.getLocation().getBlock().isLiquid() + " " + player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid());
return true;
}
// Check if player is in a boat
Entity playersVehicle = player.getVehicle();
if (playersVehicle != null) {
// They are in a Vehicle
if (playersVehicle.getType().equals(EntityType.BOAT)) {
// I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT!
if (DEBUG)
plugin.getLogger().info("DEBUG: boat");
return true;
}
}
// Check if full armor protects
if (Settings.fullArmorProtection) {
boolean fullArmor = true;
for (ItemStack item : player.getInventory().getArmorContents()) {
if (item == null || (item != null && item.getType().equals(Material.AIR))) {
fullArmor = false;
break;
}
}
if (fullArmor) {
if (DEBUG)
plugin.getLogger().info("DEBUG: full armor");
return true;
}
}
// Check if player has an active water potion or not
Collection<PotionEffect> activePotions = player.getActivePotionEffects();
for (PotionEffect s : activePotions) {
// s.getType().toString());
if (s.getType().equals(PotionEffectType.WATER_BREATHING)) {
// Safe!
if (DEBUG)
plugin.getLogger().info("DEBUG: Water breathing potion protection!");
return true;
}
}
// Check if water above sea-level is not acid
Island island = plugin.getGrid().getIslandAt(player.getLocation());
if (island != null && !island.getIgsFlag(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) {
if (DEBUG)
plugin.getLogger().info("DEBUG:no acid damage above sea level 1");
return true;
}
if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) {
if (DEBUG)
plugin.getLogger().info("DEBUG: no acid damage above sea level");
return true;
}
if (DEBUG)
plugin.getLogger().info("DEBUG: burn in acid");
return false;
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class EntityLimits method onPlayerBlockPlace.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBlockPlace(final HangingPlaceEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info("DEBUG: block placed " + e.getBlock().getType());
plugin.getLogger().info("DEBUG: entity " + e.getEntity().getType());
}
if (Settings.allowedFakePlayers.contains(e.getPlayer().getName()))
return;
// plugin.getLogger().info(e.getEventName());
if (IslandGuard.inWorld(e.getPlayer())) {
// This permission bypasses protection
if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation());
// Outside of island protection zone
if (island == null) {
if (!Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
e.setCancelled(true);
}
return;
}
if (island.getIgsFlag(SettingsFlag.PLACE_BLOCKS) || island.getMembers().contains(e.getPlayer().getUniqueId())) {
// Check how many placed
String type = e.getEntity().getType().toString();
if (e.getEntity().getType().equals(EntityType.ITEM_FRAME) || e.getEntity().getType().equals(EntityType.PAINTING)) {
// tile entity placed
if (Settings.limitedBlocks.containsKey(type) && Settings.limitedBlocks.get(type) > -1) {
// Convert from EntityType to Material via string - ugh
int count = island.getTileEntityCount(Material.valueOf(type), e.getEntity().getWorld());
if (Settings.limitedBlocks.get(type) <= count) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(type))).replace("[number]", String.valueOf(Settings.limitedBlocks.get(type))));
e.setCancelled(true);
return;
}
}
}
} else {
// Visitor
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class EntityLimits method onPlayerBlockPlace.
/**
* Prevents placing of blocks
*
* @param e - event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBlockPlace(final BlockPlaceEvent e) {
if (DEBUG) {
plugin.getLogger().info("DEBUG: " + e.getEventName());
if (e.getPlayer() == null) {
plugin.getLogger().info("DEBUG: player is null");
} else {
plugin.getLogger().info("DEBUG: block placed by " + e.getPlayer().getName());
}
plugin.getLogger().info("DEBUG: Block is " + e.getBlock().toString());
}
if (Settings.allowedFakePlayers.contains(e.getPlayer().getName()))
return;
// plugin.getLogger().info(e.getEventName());
if (IslandGuard.inWorld(e.getPlayer())) {
// This permission bypasses protection
if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// plugin.getLogger().info("DEBUG: checking is inside protection area");
Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation());
// Outside of island protection zone
if (island == null) {
if (!Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
e.setCancelled(true);
}
return;
}
if (actionAllowed(e.getPlayer(), e.getBlock().getLocation(), SettingsFlag.PLACE_BLOCKS)) {
// Check how many placed
// plugin.getLogger().info("DEBUG: block placed " + e.getBlock().getType());
String type = e.getBlock().getType().toString();
if (!e.getBlock().getState().getClass().getName().endsWith("CraftBlockState") || // Not all blocks have that type of class, so we have to do some explicit checking...
e.getBlock().getType().equals(Material.REDSTONE_COMPARATOR_OFF) || // Avoids V1.7 issues
type.endsWith("BANNER") || e.getBlock().getType().equals(Material.ENDER_CHEST) || e.getBlock().getType().equals(Material.ENCHANTMENT_TABLE) || e.getBlock().getType().equals(Material.DAYLIGHT_DETECTOR) || e.getBlock().getType().equals(Material.FLOWER_POT)) {
// tile entity placed
if (Settings.limitedBlocks.containsKey(type) && Settings.limitedBlocks.get(type) > -1) {
int count = island.getTileEntityCount(e.getBlock().getType(), e.getBlock().getWorld());
// plugin.getLogger().info("DEBUG: count is "+ count);
if (Settings.limitedBlocks.get(type) <= count) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(type))).replace("[number]", String.valueOf(Settings.limitedBlocks.get(type))));
e.setCancelled(true);
return;
}
}
}
} else {
// Visitor
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
}
use of com.wasteofplastic.acidisland.Island in project acidisland by tastybento.
the class EntityLimits method onTreeGrow.
/**
* Prevents trees from growing outside of the protected area.
*
* @param e - event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
// Check world
if (!IslandGuard.inWorld(e.getLocation())) {
return;
}
// Check if this is on an island
Island island = plugin.getGrid().getIslandAt(e.getLocation());
if (island == null || island.isSpawn()) {
return;
}
Iterator<BlockState> it = e.getBlocks().iterator();
while (it.hasNext()) {
BlockState b = it.next();
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2 || b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
if (!island.onIsland(b.getLocation())) {
it.remove();
}
}
}
}
Aggregations