use of org.bukkit.event.EventHandler in project xAuth by CypherX.
the class xAuthEntityListener method onEntityDamage.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player && ((Player) entity).isOnline()) {
// player taking damage
xAuthPlayer xp = plyrMngr.getPlayer(((Player) entity).getName());
if (plyrMngr.isRestricted(xp, event) || plyrMngr.hasGodmode(xp, event.getCause()))
event.setCancelled(true);
}
if (event instanceof EntityDamageByEntityEvent) {
// player dealing damage to other entity
EntityDamageByEntityEvent edbeEvent = (EntityDamageByEntityEvent) event;
Entity damager = edbeEvent.getDamager();
if (damager instanceof Player) {
xAuthPlayer player = plyrMngr.getPlayer(((Player) damager).getName());
if (plyrMngr.isRestricted(player, edbeEvent)) {
plyrMngr.sendNotice(player);
event.setCancelled(true);
}
}
}
}
use of org.bukkit.event.EventHandler in project xAuth by CypherX.
the class xAuthPlayerListener method onPlayerInteract.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
xAuthPlayer p = plyrMngr.getPlayer(event.getPlayer().getName());
if (plyrMngr.isRestricted(p, event)) {
Action action = event.getAction();
Material type = event.getClickedBlock().getType();
// TODO add missing blocks
if (action == Action.LEFT_CLICK_BLOCK) {
if (type == Material.NOTE_BLOCK || type == Material.WOODEN_DOOR || type == Material.LEVER || type == Material.IRON_DOOR || type == Material.STONE_BUTTON || type == Material.TRAP_DOOR) {
plyrMngr.sendNotice(p);
event.setCancelled(true);
}
} else if (action == Action.RIGHT_CLICK_BLOCK) {
if (type == Material.DISPENSER || type == Material.NOTE_BLOCK || type == Material.BED || type == Material.CHEST || type == Material.WORKBENCH || type == Material.FURNACE || type == Material.SIGN || type == Material.WOODEN_DOOR || type == Material.LEVER || type == Material.IRON_DOOR || type == Material.STONE_BUTTON || type == Material.JUKEBOX || type == Material.TRAP_DOOR || type == Material.ENCHANTMENT_TABLE) {
plyrMngr.sendNotice(p);
event.setCancelled(true);
}
} else if (action == Action.PHYSICAL) {
if (type == Material.SOIL || type == Material.STONE_PLATE || type == Material.WOOD_PLATE)
event.setCancelled(true);
}
}
}
use of org.bukkit.event.EventHandler in project xAuth by CypherX.
the class xAuthPlayerListener method onPlayerMove.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
xAuthPlayer p = plyrMngr.getPlayer(event.getPlayer());
if (plyrMngr.isRestricted(p, event)) {
World w = p.getPlayer().getWorld();
Location loc = plugin.getConfig().getBoolean("guest.protect-location") ? plugin.getLocMngr().getLocation(w) : p.getPlayerData().getLocation();
Location testLoc = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());
while ((w.getBlockAt(testLoc).isEmpty() || w.getBlockAt(testLoc).isLiquid()) && testLoc.getY() >= 0) testLoc.setY((int) testLoc.getY() - 1);
if (testLoc.getY() > 0)
loc.setY(testLoc.getY() + 1);
event.setTo(loc);
plyrMngr.sendNotice(p);
}
}
use of org.bukkit.event.EventHandler in project xAuth by CypherX.
the class xAuthPlayerListener method onPlayerQuit.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event) {
xAuthPlayer p = plyrMngr.getPlayer(event.getPlayer());
if (p.isProtected())
plyrMngr.unprotect(p);
plugin.getAuthClass(p).offline(event.getPlayer().getName());
}
use of org.bukkit.event.EventHandler in project xAuth by CypherX.
the class xAuthPlayerListener method onInventoryClick.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInventoryClick(final InventoryClickEvent event) {
if (!plugin.getConfig().getBoolean("guest.hide-inventory")) {
HumanEntity entity = event.getWhoClicked();
if (entity instanceof Player) {
xAuthPlayer p = plyrMngr.getPlayer(((Player) entity).getName());
if (plyrMngr.isRestricted(p, event)) {
plyrMngr.sendNotice(p);
event.setCancelled(true);
}
}
}
}
Aggregations