use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.
the class PlayerInteractListener method onIronPlayerInteract.
@EventHandler
public void onIronPlayerInteract(PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
Block block = event.getClickedBlock();
if (block == null) {
return;
}
boolean duelHanded = XMaterial.supports(9);
if (duelHanded && event.getHand() != EquipmentSlot.valueOf("HAND")) {
return;
}
Player player = event.getPlayer();
Settings settings = settingsManager.getSettings(player);
if (!settings.isTrapDoor()) {
return;
}
Action action = event.getAction();
XMaterial material = XMaterial.matchXMaterial(block.getType());
if (action == Action.RIGHT_CLICK_BLOCK && (material == XMaterial.IRON_DOOR || material == XMaterial.IRON_TRAPDOOR)) {
if (player.isSneaking()) {
return;
}
event.setCancelled(true);
switch(material) {
case IRON_TRAPDOOR:
plugin.getCustomBlocks().toggleIronTrapdoor(event);
break;
case IRON_DOOR:
plugin.getCustomBlocks().toggleIronDoor(event);
break;
default:
break;
}
}
}
use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.
the class PlayerInteractListener method onSlabPlayerInteract.
@EventHandler
public void onSlabPlayerInteract(PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
Action action = event.getAction();
Settings settings = settingsManager.getSettings(player);
if (settings.isSlabBreaking() && action == Action.LEFT_CLICK_BLOCK) {
plugin.getCustomBlocks().modifySlab(event);
}
}
use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.
the class PlayerInteractListener method manageInstantPlaceSignsSetting.
@EventHandler
public void manageInstantPlaceSignsSetting(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
Player player = event.getPlayer();
Settings settings = settingsManager.getSettings(player);
if (!settings.isInstantPlaceSigns()) {
return;
}
ItemStack itemStack = event.getItem();
if (itemStack == null) {
return;
}
Material material = itemStack.getType();
XMaterial xMaterial = XMaterial.matchXMaterial(itemStack);
if (!XTag.SIGNS.isTagged(xMaterial)) {
return;
}
Block clickedBlock = event.getClickedBlock();
BlockFace blockFace = event.getBlockFace();
if (clickedBlock == null || blockFace == BlockFace.DOWN) {
return;
}
Block adjacent = clickedBlock.getRelative(blockFace);
if (adjacent.getType() != XMaterial.AIR.parseMaterial()) {
return;
}
event.setUseItemInHand(Event.Result.DENY);
event.setCancelled(true);
switch(blockFace) {
case UP:
if (!XMaterial.supports(13)) {
material = Material.getMaterial("SIGN_POST") != null ? Material.valueOf("SIGN_POST") : material;
}
adjacent.setType(material);
plugin.getCustomBlocks().rotate(adjacent, player, getDirection(player).getOppositeFace());
break;
case NORTH:
case EAST:
case SOUTH:
case WEST:
String type = xMaterial.name().replace("_SIGN", "");
XMaterial.matchXMaterial(type + "_WALL_SIGN").ifPresent(value -> adjacent.setType(value.parseMaterial()));
plugin.getCustomBlocks().rotate(adjacent, player, blockFace);
break;
default:
break;
}
}
use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.
the class PlayerInteractListener method openNavigator.
private void openNavigator(Player player) {
Settings settings = settingsManager.getSettings(player);
if (settings.getNavigatorType() == NavigatorType.OLD) {
plugin.getNavigatorInventory().openInventory(player);
XSound.BLOCK_CHEST_OPEN.play(player);
} else {
// NEW
if (playerManager.getOpenNavigator().contains(player)) {
player.sendMessage(plugin.getString("worlds_navigator_open"));
return;
}
summonNewNavigator(player);
String findItemName = plugin.getString("navigator_item");
ItemStack replaceItem = inventoryManager.getItemStack(XMaterial.BARRIER, plugin.getString("barrier_item"));
inventoryManager.replaceItem(player, findItemName, configValues.getNavigatorItem(), replaceItem);
}
}
use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.
the class PlayerInventoryClearListener method onPlayerInventoryClear.
@EventHandler
public void onPlayerInventoryClear(PlayerInventoryClearEvent event) {
Player player = event.getPlayer();
Settings settings = settingsManager.getSettings(player);
if (!settings.isKeepNavigator()) {
return;
}
if (!player.hasPermission("buildsystem.gui")) {
return;
}
PlayerInventory playerInventory = player.getInventory();
ItemStack navigatorItem = inventoryManager.getItemStack(plugin.getConfigValues().getNavigatorItem(), plugin.getString("navigator_item"));
event.getNavigatorSlots().forEach(slot -> playerInventory.setItem(slot, navigatorItem));
}
Aggregations