Java Code Examples for org.bukkit.entity.Player#hasPotionEffect()

The following examples show how to use org.bukkit.entity.Player#hasPotionEffect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shulking.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
	if (!this.givesImmunity) return;

	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.shulking.use")) {
		return;
	}

	boolean hasShulking = false;
	ItemStack armor = null;
	for (ItemStack stack : player.getInventory().getArmorContents()) {
		if (stack == null) continue;
		if (modManager.hasMod(stack, this)) {
			hasShulking = true;
			armor = stack;
			break;
		}
	}

	if (!hasShulking) return;
	if (player.hasPotionEffect(PotionEffectType.LEVITATION)) {
		player.removePotionEffect(PotionEffectType.LEVITATION);
		ChatWriter.logModifier(player, event, this, armor, "RemoveEffect");
	}
}
 
Example 2
Source File: ShadowDive.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
private void hidePlayer(Player p) {
	activePlayers.add(p);

	//Clear all mob targets
	Collection<Entity> nearbyEntities = p.getWorld().getNearbyEntities(p.getLocation(), 64, 64, 64);
	for (Entity ent : nearbyEntities) {
		if (ent instanceof Creature) {
			if (p.equals(((Creature) ent).getTarget())) {
				((Creature) ent).setTarget(null);
			}
		}
	}

	//Hide from all players
	for (Player player : Bukkit.getServer().getOnlinePlayers()) {
		if (!p.equals(player)) {
			if (!player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) player.hidePlayer(MineTinker.getPlugin(), p);
		}
	}
}
 
Example 3
Source File: Webbed.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
	if (!this.givesImmunity) return;

	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.webbed.use")) {
		return;
	}

	boolean hasWebbed = false;
	ItemStack armor = null;
	for (ItemStack stack : player.getInventory().getArmorContents()) {
		if (stack == null) continue;
		if (modManager.hasMod(stack, this)) {
			hasWebbed = true;
			armor = stack;
			break;
		}
	}

	if (!hasWebbed) return;
	if (player.hasPotionEffect(PotionEffectType.SLOW)) {
		player.removePotionEffect(PotionEffectType.SLOW);
		ChatWriter.logModifier(player, event, this, armor, "RemoveEffect");
	}
}
 
Example 4
Source File: BloodMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
        if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
            EntityUtils.entities(match.getWorld(), Player.class)
                 .filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
                 .forEach(player -> {
                     if(event instanceof EntityDamageByEntityEvent) {
                         player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
                     } else {
                         player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
                     }
                 });
        }
    }
}
 
Example 5
Source File: Scotopic.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onMoveImmune(PlayerMoveEvent event) {
	if (!this.givesImmunity) return;

	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.scotopic.use")) {
		return;
	}

	ItemStack armor = player.getInventory().getHelmet();
	if (armor == null) return;

	if (!modManager.hasMod(armor, this)) return;
	if (player.hasPotionEffect(PotionEffectType.BLINDNESS)) {
		player.removePotionEffect(PotionEffectType.BLINDNESS);
		ChatWriter.logModifier(player, event, this, armor, "RemoveBlindness");
	}
}
 
Example 6
Source File: PricklyBlock.java    From ce with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean effect(Event event, Player player) {
	if(event instanceof BlockPlaceEvent) {
		BlockPlaceEvent e = (BlockPlaceEvent) event;
		Block b = e.getBlock();
		b.setMetadata("ce.mine", new FixedMetadataValue(main, getOriginalName()));
		String coord = b.getX() + " " + b.getY() + " " + b.getZ();
		b.getRelative(0,1,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(0,-1,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(1,0,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(0,0,1).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(0,0,-1).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(-1,0,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
	} else if(event instanceof PlayerMoveEvent) {
		if(!player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPotionEffect(PotionEffectType.CONFUSION)) {
			player.damage(Damage);
			player.sendMessage(ChatColor.DARK_GREEN + "A nearbly Block is hurting you!");
			player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, NauseaDuration, NauseaLevel));
		}
	}
	return false;
}
 
Example 7
Source File: Vitamins.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Player p = e.getPlayer();

        if (p.getGameMode() != GameMode.CREATIVE) {
            ItemUtils.consumeItem(e.getItem(), false);
        }

        p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);

        if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
        if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
        if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
        if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
        if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
        if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
        if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);

        p.setFireTicks(0);
        p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 2));

        e.cancel();
    };
}
 
Example 8
Source File: ShadowDive.java    From MineTinker with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
	Iterator<Player> iterator = activePlayers.iterator();
	//noinspection WhileLoopReplaceableByForEach
	while (iterator.hasNext()) {
		Player p = iterator.next();
		Location loc = p.getLocation();
		byte lightlevel = p.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()).getLightLevel();
		if (!p.isSneaking() || lightlevel > requiredLightLevel || p.hasPotionEffect(PotionEffectType.GLOWING)) {
			showPlayer(p);
			ChatWriter.sendActionBar(p, ChatColor.RED + ShadowDive.instance().getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.LightToHigh", p));
		} else if (PlayerInfo.isCombatTagged(p)) {
			showPlayer(p);
			ChatWriter.sendActionBar(p, ChatColor.RED + ShadowDive.instance().getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.InCombat", p));
		} else {
			for(Player pl : Bukkit.getOnlinePlayers()) {
				if (pl.equals(p)) continue;
				if (pl.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
					pl.showPlayer(MineTinker.getPlugin(), p);
				} else {
					pl.hidePlayer(MineTinker.getPlugin(), p);
				}
			}
		}
	}
}
 
Example 9
Source File: ShadowDive.java    From MineTinker with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onSneak(PlayerToggleSneakEvent event) {
	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.shadowdive.use")) return;

	ItemStack boots = player.getInventory().getBoots();
	if (!modManager.isArmorViable(boots)) return;
	if (!modManager.hasMod(boots, this)) return;

	if (event.isSneaking() && !player.isGliding()) { //enable
		Location loc = player.getLocation();
		byte lightlevel = player.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()).getLightLevel();
		boolean combatTagged = PlayerInfo.isCombatTagged(player);
		ChatWriter.logModifier(player, event, this, boots,
				String.format("LightLevel(%d/%d)", lightlevel, this.requiredLightLevel),
				String.format("InCombat(%b)", combatTagged));
		if (lightlevel > this.requiredLightLevel || player.hasPotionEffect(PotionEffectType.GLOWING)) {
			ChatWriter.sendActionBar(player, ChatColor.RED + this.getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.LightToHigh", player));
			return;
		}

		if (combatTagged) {
			ChatWriter.sendActionBar(player, ChatColor.RED + this.getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.InCombat", player));
			return;
		}

		hidePlayer(player);

	} else { //disable
		if (!activePlayers.contains(player)) return;
		showPlayer(player);
	}
}
 
Example 10
Source File: QAMain.java    From QualityArmory with GNU General Public License v3.0 5 votes vote down vote up
public static void toggleNightvision(Player player, Gun g, boolean add) {
	if (add) {
		if (g.getZoomWhenIronSights() > 0) {
			currentlyScoping.add(player.getUniqueId());
			player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1200, g.getZoomWhenIronSights()));
		}
		if (g.hasnightVision()) {
			currentlyScoping.add(player.getUniqueId());
			player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1200, 3));
		}
	} else {
		if (currentlyScoping.contains(player.getUniqueId())) {
			if (player.hasPotionEffect(PotionEffectType.SLOW) && (g == null || g.getZoomWhenIronSights() > 0))
				player.removePotionEffect(PotionEffectType.SLOW);
			boolean potionEff = false;
			try {
				potionEff = player.hasPotionEffect(PotionEffectType.NIGHT_VISION)
						&& (g == null || g.hasnightVision())
						&& player.getPotionEffect(PotionEffectType.NIGHT_VISION).getAmplifier() == 3;
			} catch (Error | Exception e3452) {
				for (PotionEffect pe : player.getActivePotionEffects())
					if (pe.getType() == PotionEffectType.NIGHT_VISION)
						potionEff = (g == null || g.hasnightVision()) && pe.getAmplifier() == 3;
			}
			if (potionEff)
				player.removePotionEffect(PotionEffectType.NIGHT_VISION);
			currentlyScoping.remove(player.getUniqueId());
		}
	}

}
 
Example 11
Source File: InvisibilityListeners.java    From AnnihilationPro with MIT License 5 votes vote down vote up
private void checkInvis(Player player)
{
	if(player.hasPotionEffect(PotionEffectType.INVISIBILITY))
	{
		player.removePotionEffect(PotionEffectType.INVISIBILITY);
		player.sendMessage(Lang.INVISREVEAL.toString());
	}
}
 
Example 12
Source File: PoisonIvy.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean effect(Event event, Player player) {
	if(event instanceof BlockPlaceEvent) {
		BlockPlaceEvent e = (BlockPlaceEvent) event;
		e.getBlock().setMetadata("ce.mine", new FixedMetadataValue(main, getOriginalName()));
	} else if(event instanceof PlayerMoveEvent) {
		if(!player.hasPotionEffect(PotionEffectType.POISON)) {
			player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, PoisonDuration, PoisonLevel));
			player.sendMessage(ChatColor.DARK_GREEN + "You have touched Poison Ivy!");
		}
	}
	return false;
}
 
Example 13
Source File: Talisman.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private static boolean pass(Player p, SlimefunItem talisman) {
    for (PotionEffect effect : ((Talisman) talisman).getEffects()) {
        if (effect != null && p.hasPotionEffect(effect.getType())) {
            return false;
        }
    }

    return true;
}
 
Example 14
Source File: SpectatorTools.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    ItemStack item = event.getCurrentItem();
    Player player = (Player) event.getWhoClicked();
    String locale = player.getLocale();
    if (item == null) return;
    if (event.getInventory().getName().equals(getSpectatorMenuTitle(event.getActor().getLocale()))) {
        if (item.isSimilar(getTeleportItem(locale))) {
            player.openInventory(getTeamsMenu(player));
        } else if (item.isSimilar(getVisibilityItem(locale))) {
            Bukkit.dispatchCommand(player, "toggle obs");
            player.closeInventory();
        } else if (item.isSimilar(getElytraItem(locale))) {
            Bukkit.dispatchCommand(player, "toggle elytra");
            player.closeInventory();
        } else if (item.isSimilar(getEffectsItem(locale))) {
            player.openInventory(getEffectsMenu(player));
        } else if (item.isSimilar(getGamemodeItem(locale))) {
            player.setGameMode(player.getGameMode().equals(GameMode.CREATIVE) ? GameMode.SPECTATOR : GameMode.CREATIVE);
            if (player.getGameMode().equals(GameMode.CREATIVE)) Bukkit.dispatchCommand(player, "!");
            player.closeInventory();
        }
    } else if (event.getInventory().getName().equals(getTeamsMenuTitle(locale))) {
        if (item.isSimilar(getGoBackItem(locale))) {
            player.openInventory(getSpectatorMenu(player));
        } else if (item.getType().equals(Material.LEATHER_HELMET) && item.getItemMeta().hasDisplayName() && !item.isSimilar(TeamPicker.getTeamPicker(locale))){
            TeamModule team = Teams.getTeamByName(ChatColor.stripColor(Strings.removeLastWord(item.getItemMeta().getDisplayName()))).orNull();
            if (team != null) {
                player.openInventory(getTeleportMenu(player, team));
            }
        }
    } else if (event.getInventory().getName().equals(getTeleportMenuTitle(locale))) {
        if (item.isSimilar(getGoBackItem(locale))) {
            player.openInventory(getTeamsMenu(player));
        } else if (item.getType().equals(Material.SKULL_ITEM) && item.getItemMeta().hasDisplayName()) {
            Player teleport = Bukkit.getPlayer(((SkullMeta) item.getItemMeta()).getOwner());
            if (teleport != null) {
                player.teleport(teleport);
                player.closeInventory();
            }
        }
    } else if (event.getInventory().getName().equals(getEffectsMenuTitle(locale))) {
        if (item.isSimilar(getGoBackItem(locale))) {
            player.openInventory(getSpectatorMenu(player));
        } else if (item.isSimilar(getNightVisionItem(player.getLocale()))) {
            if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
                player.removePotionEffect(PotionEffectType.NIGHT_VISION);
            } else {
                player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
            }
            player.closeInventory();
        } else if (item.getType().equals(Material.SUGAR) && item.getItemMeta().hasDisplayName()) {
            int value = event.getSlot();
            Setting setting = Settings.getSettingByName("Speed");
            Bukkit.dispatchCommand(player, "set speed " + setting.getValues().get(value).getValue());
            player.closeInventory();
        }
    }
}
 
Example 15
Source File: CommandGuildEffect.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute(CommandSender sender, String[] args) throws Exception {
	NovaPlayer nPlayer = PlayerManager.getPlayer(sender);
	Player player = (Player) sender;

	if(!nPlayer.hasGuild()) {
		Message.CHAT_GUILD_NOTINGUILD.send(sender);
		return;
	}

	if(!nPlayer.hasPermission(GuildPermission.EFFECT)) {
		Message.CHAT_GUILD_NOGUILDPERM.send(sender);
		return;
	}

	//Money
	double money = GroupManager.getGroup(sender).get(NovaGroupImpl.Key.EFFECT_MONEY);
	if(!nPlayer.getGuild().hasMoney(money)) {
		Message.CHAT_GUILD_NOTENOUGHMONEY.send(sender);
		return;
	}

	//items
	List<ItemStack> guildEffectItems = GroupManager.getGroup(sender).get(NovaGroupImpl.Key.EFFECT_ITEMS);
	if(!guildEffectItems.isEmpty()) {
		List<ItemStack> missingItems = InventoryUtils.getMissingItems(player.getInventory(), guildEffectItems);

		if(!missingItems.isEmpty()) {
			Message.CHAT_CREATEGUILD_NOITEMS.send(sender);
			sender.sendMessage(StringUtils.getItemList(missingItems));
			return;
		}
	}

	//Generate effect
	List<PotionEffectType> potionEffects = plugin.getConfigManager().getGuildEffects();
	int index = NumberUtils.randInt(0, potionEffects.size() - 1);
	PotionEffectType effectType = potionEffects.get(index);
	PotionEffect effect = effectType.createEffect(Config.GUILD_EFFECT_DURATION.getSeconds() * 20, 1);


	//add effect
	for(Player gPlayer : nPlayer.getGuild().getOnlinePlayers()) {
		if(gPlayer.hasPotionEffect(effectType)) {
			gPlayer.removePotionEffect(effectType);
		}

		gPlayer.addPotionEffect(effect);
	}

	//remove money and items
	nPlayer.getGuild().takeMoney(money);
	InventoryUtils.removeItems(player, guildEffectItems);

	//message
	Message.CHAT_GUILD_EFFECT_SUCCESS.clone().setVar(VarKey.EFFECTTYPE, effectType.getName()).send(sender);
}
 
Example 16
Source File: Esp.java    From AACAdditionPro with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Determines if two {@link User}s can see each other.
 */
private boolean canSee(final User observerUser, final User watchedUser)
{
    final Player observer = observerUser.getPlayer();
    final Player watched = watchedUser.getPlayer();

    // Not bypassed
    if (observerUser.isBypassed(this.getModuleType()) ||
        // Has not logged in recently to prevent bugs
        observerUser.hasLoggedInRecently(3000) ||
        // Glowing handling
        // Glowing does not exist in 1.8.8
        (ServerVersion.getActiveServerVersion() != ServerVersion.MC188 &&
         // If an entity is glowing it can always be seen.
         watched.hasPotionEffect(PotionEffectType.GLOWING)))
    {
        return true;
    }

    // ----------------------------------- Calculation ---------------------------------- //

    final Vector[] cameraVectors = VectorUtils.getCameraVectors(observer);

    // Get the Vectors of the hitbox to check.
    final Vector[] watchedHitboxVectors = (watched.isSneaking() ?
                                           Hitbox.ESP_SNEAKING_PLAYER :
                                           Hitbox.ESP_PLAYER).getCalculationVectors(watched.getLocation(), true);

    // The distance of the intersections in the same block is equal as of the
    // BlockIterator mechanics.
    final Set<Double> lastIntersectionsCache = new HashSet<>();

    for (Vector cameraVector : cameraVectors) {
        for (final Vector destinationVector : watchedHitboxVectors) {
            final Location start = cameraVector.toLocation(observer.getWorld());
            // The resulting Vector
            // The camera is not blocked by non-solid blocks
            // Vector is intersecting with some blocks
            //
            // Cloning IS needed as we are in a second loop.
            final Vector between = destinationVector.clone().subtract(cameraVector);

            // ---------------------------------------------- FOV ----------------------------------------------- //
            final Vector cameraRotation = cameraVector.clone().subtract(observer.getLocation().toVector());

            if (cameraRotation.angle(between) > MAX_FOV) {
                continue;
            }

            // ---------------------------------------- Cache Calculation --------------------------------------- //

            // Make sure the chunks are loaded.
            if (!ChunkUtils.areChunksLoadedBetweenLocations(start, start.clone().add(between))) {
                // If the chunks are not loaded assume the players can see each other.
                return true;
            }

            boolean cacheHit = false;

            Location cacheLocation;
            for (Double length : lastIntersectionsCache) {
                cacheLocation = start.clone().add(between.clone().normalize().multiply(length));

                // Not yet cached.
                if (length == 0) {
                    continue;
                }

                final Material type = cacheLocation.getBlock().getType();

                if (BlockUtils.isReallyOccluding(type) && type.isSolid()) {
                    cacheHit = true;
                    break;
                }
            }

            if (cacheHit) {
                continue;
            }

            // --------------------------------------- Normal Calculation --------------------------------------- //

            final double intersect = VectorUtils.getDistanceToFirstIntersectionWithBlock(start, between);

            // No intersection found
            if (intersect == 0) {
                return true;
            }

            lastIntersectionsCache.add(intersect);
        }
    }

    // Low probability to help after the camera view was changed. -> clearing
    lastIntersectionsCache.clear();
    return false;
}
 
Example 17
Source File: EntityToggleGlideListener.java    From ViaVersion with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void entityToggleGlide(EntityToggleGlideEvent event) {
    if (!(event.getEntity() instanceof Player)) return;

    Player player = (Player) event.getEntity();
    if (!isOnPipe(player)) return;

    // Cancelling can only be done by updating the player's metadata
    if (event.isGliding() && event.isCancelled()) {
        PacketWrapper packet = new PacketWrapper(0x44, null, getUserConnection(player));
        try {
            packet.write(Type.VAR_INT, player.getEntityId());

            byte bitmask = 0;
            // Collect other metadata for the mitmask
            if (player.getFireTicks() > 0) {
                bitmask |= 0x01;
            }
            if (player.isSneaking()) {
                bitmask |= 0x02;
            }
            // 0x04 is unused
            if (player.isSprinting()) {
                bitmask |= 0x08;
            }
            if (swimmingMethodExists && player.isSwimming()) {
                bitmask |= 0x10;
            }
            if (player.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                bitmask |= 0x20;
            }
            if (player.isGlowing()) {
                bitmask |= 0x40;
            }

            // leave 0x80 as 0 to stop gliding
            packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, MetaType1_14.Byte, bitmask)));
            packet.send(Protocol1_15To1_14_4.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}