use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.
the class PrismInventoryMoveItemEvent method onInventoryMoveItem.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItem(final InventoryMoveItemEvent event) {
// Hopper inserted
if (Prism.getIgnore().event("item-insert") && event.getDestination() != null) {
// Get container
final InventoryHolder ih = event.getDestination().getHolder();
Location containerLoc = null;
if (ih instanceof BlockState) {
final BlockState eventChest = (BlockState) ih;
containerLoc = eventChest.getLocation();
}
if (containerLoc == null)
return;
if (event.getSource().getType().equals(InventoryType.HOPPER)) {
RecordingQueue.addToQueue(ActionFactory.createItemStack("item-insert", event.getItem(), event.getItem().getAmount(), 0, null, containerLoc, "hopper"));
}
}
// Hopper removed
if (Prism.getIgnore().event("item-remove") && event.getSource() != null) {
// Get container
final InventoryHolder ih = event.getSource().getHolder();
Location containerLoc = null;
if (ih instanceof BlockState) {
final BlockState eventChest = (BlockState) ih;
containerLoc = eventChest.getLocation();
}
if (containerLoc == null)
return;
if (event.getDestination().getType().equals(InventoryType.HOPPER)) {
RecordingQueue.addToQueue(ActionFactory.createItemStack("item-remove", event.getItem(), event.getItem().getAmount(), 0, null, containerLoc, "hopper"));
}
}
}
use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.
the class PrismPlayerEvents method onCraftItem.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(final CraftItemEvent event) {
final Player player = (Player) event.getWhoClicked();
if (!Prism.getIgnore().event("craft-item", player))
return;
final ItemStack item = event.getRecipe().getResult();
RecordingQueue.addToQueue(ActionFactory.createItemStack("craft-item", item, 1, -1, null, player.getLocation(), player.getName()));
}
use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.
the class PrismPlayerEvents method onCommandPreprocess.
/**
* Log command use
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
final Player player = event.getPlayer();
final String cmd = event.getMessage().toLowerCase();
final String[] cmdArgs = cmd.split(" ");
final String primaryCmd = cmdArgs[0].substring(1);
if (plugin.getConfig().getBoolean("prism.alerts.illegal-commands.enabled")) {
if (illegalCommands.contains(primaryCmd)) {
final String msg = player.getName() + " attempted an illegal command: " + primaryCmd + ". Originally: " + cmd;
player.sendMessage(Prism.messenger.playerError("Sorry, this command is not available in-game."));
plugin.alertPlayers(null, msg);
event.setCancelled(true);
// Log to console
if (plugin.getConfig().getBoolean("prism.alerts.illegal-commands.log-to-console")) {
Prism.log(msg);
}
// Log to commands
List<String> commands = plugin.getConfig().getStringList("prism.alerts.illegal-commands.log-commands");
MiscUtils.dispatchAlert(msg, commands);
}
}
if (!Prism.getIgnore().event("player-command", player))
return;
// Ignore some commands based on config
if (ignoreCommands.contains(primaryCmd)) {
return;
}
RecordingQueue.addToQueue(ActionFactory.createPlayer("player-command", player, event.getMessage()));
}
use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.
the class PrismPlayerEvents method onPlayerBucketFill.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
final Player player = event.getPlayer();
if (!Prism.getIgnore().event("bucket-fill", player))
return;
final Block spot = event.getBlockClicked().getRelative(event.getBlockFace());
String liquid_type = "milk";
if (spot.getTypeId() == 8 || spot.getTypeId() == 9) {
liquid_type = "water";
} else if (spot.getTypeId() == 10 || spot.getTypeId() == 11) {
liquid_type = "lava";
}
final Handler pa = ActionFactory.createPlayer("bucket-fill", player, liquid_type);
// Override the location with the area taken
pa.setX(spot.getX());
pa.setY(spot.getY());
pa.setZ(spot.getZ());
RecordingQueue.addToQueue(pa);
}
use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.
the class PrismPlayerEvents method onPlayerJoin.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
// Lookup player for cache reasons
PlayerIdentification.cachePrismPlayer(player);
// Track the join event
if (!Prism.getIgnore().event("player-join", player))
return;
String ip = null;
if (plugin.getConfig().getBoolean("prism.track-player-ip-on-join")) {
ip = player.getAddress().getAddress().getHostAddress().toString();
}
RecordingQueue.addToQueue(ActionFactory.createPlayer("player-join", event.getPlayer(), ip));
}
Aggregations