use of me.lexikiq.HasPlayer in project Nexus by ProjectEdenGG.
the class AbstractTaskMenu method scheduleInvClose.
// todo: use for more tasks
public void scheduleInvClose(HasPlayer _player) {
Player player = _player.getPlayer();
Minigamer minigamer = PlayerManager.get(player);
// don't schedule if match just ended
if (!minigamer.isPlaying(Sabotage.class))
return;
Match.MatchTasks tasks = minigamer.getMatch().getTasks();
if (closeInvTasks.containsKey(player.getUniqueId()))
tasks.cancel(closeInvTasks.remove(player.getUniqueId()));
closeInvTasks.put(player.getUniqueId(), tasks.wait(20, () -> {
player.sendMessage(Sabotage.COMPLETED_TASK_TEXT);
player.closeInventory();
}));
}
use of me.lexikiq.HasPlayer in project Nexus by ProjectEdenGG.
the class WorldGuardFlagUtils method hasBypass.
/**
* Tests if a player bypasses world guard flags
* @param player player
* @return if the player bypasses world guard flags
*/
public static boolean hasBypass(@NotNull HasPlayer player) {
Validate.notNull(player, "Player cannot be null");
Player _player = player.getPlayer();
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(WorldGuardPlugin.inst().wrapPlayer(_player), BukkitAdapter.adapt(_player.getWorld()));
}
use of me.lexikiq.HasPlayer in project Nexus by ProjectEdenGG.
the class LocationUtils method lookAt.
/**
* Sets a player's pitch and yaw to look at the provided location.
*/
public static void lookAt(HasPlayer hasPlayer, Location lookAt) {
Player player = hasPlayer.getPlayer();
Vector direction = player.getEyeLocation().toVector().subtract(lookAt.add(0.5, 0.5, 0.5).toVector()).normalize();
double x = direction.getX();
double y = direction.getY();
double z = direction.getZ();
// Now change the angle
Location changed = player.getLocation().clone();
changed.setYaw(180 - toDegree(Math.atan2(x, z)));
changed.setPitch(90 - toDegree(Math.acos(y)));
player.teleport(changed);
}
use of me.lexikiq.HasPlayer in project Nexus by ProjectEdenGG.
the class BlockUtils method getBlockStandingOn.
/*
Doesnt work:
fences
gates
walls
sea pickles
pot
hanging on all vines
in a cobweb
on a ladder (and on top)
end rods
trapdoors (uses the block underneath)
carpet (uses the block underneath)
scaffolding
lily pads
composter (inside)
skulls (on floor & wall)
in water & lava
snow layers (all levels, layers=1 & 2, uses the block underneath)
*/
public static Block getBlockStandingOn(HasPlayer hasPlayer) {
Player player = hasPlayer.getPlayer();
Location below = player.getLocation().add(0, -.25, 0);
Block block = below.getBlock();
if (block.getType().isSolid())
return block;
List<BlockFace> priority = new HashMap<BlockFace, Double>() {
{
put(BlockFace.NORTH, below.getZ() - Math.floor(below.getZ()));
put(BlockFace.EAST, Math.abs(below.getX() - Math.ceil(below.getX())));
put(BlockFace.SOUTH, Math.abs(below.getZ() - Math.ceil(below.getZ())));
put(BlockFace.WEST, below.getX() - Math.floor(below.getX()));
}
}.entrySet().stream().filter(direction -> direction.getValue() < .3).sorted(Map.Entry.comparingByValue()).map(Map.Entry::getKey).limit(2).collect(Collectors.toList());
if (priority.size() == 2)
priority.add(getBlockFaceBetween(priority.get(0), priority.get(1)));
for (BlockFace blockFace : priority) {
Block relative = block.getRelative(blockFace);
if (relative.getType().isSolid())
return relative;
}
return null;
}
use of me.lexikiq.HasPlayer in project Nexus by ProjectEdenGG.
the class BearFair21Restrictions method onItemFrameBreak.
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemFrameBreak(EntityDamageByEntityEvent event) {
if (BearFair21.isNotAtBearFair(event.getEntity()))
return;
EntityType breakType = event.getEntityType();
if (!breakType.equals(EntityType.ITEM_FRAME) && !breakType.equals(EntityType.PAINTING))
return;
Entity damager = event.getDamager();
if (!(damager instanceof Player) && !(damager instanceof Projectile))
return;
if (damager instanceof Projectile) {
Entity shooter = (Entity) ((Projectile) damager).getShooter();
if (shooter instanceof Player) {
if (WorldGuardFlagUtils.hasBypass((HasPlayer) shooter))
return;
}
} else {
if (WorldGuardFlagUtils.hasBypass((HasPlayer) damager))
return;
}
event.setCancelled(true);
}
Aggregations