use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManipulateListener method onBlockBreak.
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (!manageWorldInteraction(player, event, buildWorld.isBlockBreaking())) {
setStatus(buildWorld, player);
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManipulateListener method onBlockPlace.
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (!manageWorldInteraction(player, event, buildWorld.isBlockPlacement())) {
setStatus(buildWorld, player);
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManipulateListener method onEntityDamageByEntity.
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player)) {
return;
}
Player player = (Player) event.getDamager();
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (event.getEntity() instanceof ArmorStand) {
manageWorldInteraction(player, event, buildWorld.isBlockInteractions());
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManipulateListener method manageWorldInteraction.
/**
* Not every player can always interact with the {@link BuildWorld} they are in.
* <p>
* Reasons an interaction could be cancelled:
* <ul>
* <li>The world has its {@link WorldStatus} set to archived;</li>
* <li>The world has a setting enabled which disallows certain events;</li>
* <li>The world only allows {@link Builder}s to build and the player is not such a builder.</li>
* </ul>
* <p>
* However, a player can override these reasons if:
* <ul>
* <li>The player has the permission {@code buildsystem.admin};</li>
* <li>The player has the permission {@code buildsystem.bypass.archive};</li>
* <li>The player has used {@code /build} to enter build-mode.</li>
* </ul>
*
* @param player the player who manipulated the world
* @param event the event which was called by the world manipulation
* @return if the event called when the player performs an action was cancelled
*/
private boolean manageWorldInteraction(Player player, Event event, boolean worldSetting) {
String worldName = player.getWorld().getName();
BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
if (buildWorld == null) {
return false;
}
if (disableArchivedWorlds(buildWorld, player, event)) {
return true;
}
if (checkWorldSettings(player, event, worldSetting)) {
return true;
}
if (checkBuilders(buildWorld, player, event)) {
return true;
}
return false;
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManipulateListener method onPlayerInteract.
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
ItemStack itemStack = event.getItem();
if (itemStack != null && itemStack.getType() == plugin.getConfigValues().getWorldEditWand().parseMaterial()) {
return;
}
Player player = event.getPlayer();
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
manageWorldInteraction(player, event, buildWorld.isBlockInteractions());
if (!buildWorld.isPhysics() && event.getClickedBlock() != null) {
if (event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == XMaterial.FARMLAND.parseMaterial()) {
event.setCancelled(true);
}
}
}
Aggregations