use of org.bukkit.Art in project Prism-Bukkit by prism.
the class HangingItemAction method hangItem.
/**
* Get A change result.
* @param player Player
* @param parameters Query params
* @param isPreview is preview.
* @return ChangeResult
* @todo I am not sure this actual is used during preview?? also no rollback info is saved to undo this.
*/
private ChangeResult hangItem(Player player, PrismParameters parameters, boolean isPreview) {
if (actionData == null) {
Prism.debug(parameters.getProcessType() + "Skipped - Hanging action data was null");
return new ChangeResultImpl(ChangeResultType.SKIPPED, null);
}
final BlockFace attachedFace = getDirection();
final Location loc = getLoc().getBlock().getRelative(getDirection()).getLocation();
// Ensure there's a block at this location that accepts an attachment
if (Utilities.materialMeansBlockDetachment(loc.getBlock().getType())) {
Prism.debug(parameters.getProcessType() + "Hanging Skipped - block would detach: " + loc.getBlock().getType());
return new ChangeResultImpl(ChangeResultType.SKIPPED, null);
}
try {
if (getHangingType().equals("item_frame")) {
final Hanging hangingItem = getWorld().spawn(loc, ItemFrame.class);
hangingItem.setFacingDirection(attachedFace, true);
// no change recorded
return new ChangeResultImpl(ChangeResultType.APPLIED, null);
} else if (getHangingType().equals("painting")) {
final Painting hangingItem = getWorld().spawn(loc, Painting.class);
hangingItem.setFacingDirection(getDirection(), true);
Art art = Art.getByName(getArt());
if (art != null) {
hangingItem.setArt(art);
}
// no change recorded
return new ChangeResultImpl(ChangeResultType.APPLIED, null);
}
} catch (final IllegalArgumentException e) {
// Something interfered with being able to place the painting
}
return new ChangeResultImpl(ChangeResultType.SKIPPED, null);
}
Aggregations