Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onShoot(EntityShootBowEvent event) {
- if (event.getEntity() instanceof Player) {
- Player player = (Player) event.getEntity();
- GamePlayer gamePlayer = getPlugin().getParent().getGameManager().getGamePlayer(player.getUniqueId());
- if(gamePlayer == null) {
- return;
- }
- if(gamePlayer.getGame().getState() == GameState.IN_GAME && gamePlayer.getPlayerState() == PlayerState.IN_GAME) {
- SkillData skillData = getPlugin().getDataManager().load(player.getUniqueId(), player.getName());
- if (skillData.haveSkill(this) && checkChance(skillData.getLevel(this))) {
- Arrow right = player.launchProjectile(Arrow.class);
- Arrow left = player.launchProjectile(Arrow.class);
- BlockFace direction = getDirection(player.getLocation().getYaw());
- if(direction == null) {
- return;
- }
- if (direction == BlockFace.EAST || direction == BlockFace.WEST) {
- right.setVelocity(new Vector(right.getVelocity().getX(), right.getVelocity().getY(), right.getVelocity().getZ() - 0.3D));
- left.setVelocity(new Vector(left.getVelocity().getX(), left.getVelocity().getY(), left.getVelocity().getZ() + 0.3D));
- } else {
- right.setVelocity(new Vector(right.getVelocity().getX() - 0.3D, right.getVelocity().getY(), right.getVelocity().getZ()));
- left.setVelocity(new Vector(left.getVelocity().getX() + 0.3D, left.getVelocity().getY(), left.getVelocity().getZ()));
- }
- }
- }
- }
- }
- public BlockFace getDirection(Float yaw) {
- yaw = yaw / 90.0F;
- yaw = (float) Math.round(yaw.floatValue());
- if ((yaw == -4.0F) || (yaw == 0.0F) || (yaw == 4.0F)) {
- return BlockFace.SOUTH;
- }
- if ((yaw == -1.0F) || (yaw == 3.0F)) {
- return BlockFace.EAST;
- }
- if ((yaw == -2.0F) || (yaw == 2.0F)) {
- return BlockFace.NORTH;
- }
- if ((yaw == -3.0F) || (yaw == 1.0F)) {
- return BlockFace.WEST;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement