Search in sources :

Example 51 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.

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);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 52 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.

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);
        }
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 53 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.

the class InventoryManager method teleport.

private void teleport(Player player, String worldName) {
    WorldManager worldManager = plugin.getWorldManager();
    BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
    if (buildWorld == null) {
        return;
    }
    worldManager.teleport(player, buildWorld);
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

Example 54 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.

the class PlayerCommandPreprocessListener method onPlayerCommandPreprocess.

@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    if (event.isCancelled()) {
        return;
    }
    String command = event.getMessage().split(" ")[0];
    Player player = event.getPlayer();
    if (command.equalsIgnoreCase("/clear")) {
        ItemStack navigatorItem = inventoryManager.getItemStack(configValues.getNavigatorItem(), plugin.getString("navigator_item"));
        if (!player.getInventory().contains(navigatorItem)) {
            return;
        }
        if (settingsManager.getSettings(player).isKeepNavigator()) {
            List<Integer> navigatorSlots = inventoryManager.getNavigatorSlots(player);
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                PlayerInventoryClearEvent playerInventoryClearEvent = new PlayerInventoryClearEvent(player, navigatorSlots);
                Bukkit.getServer().getPluginManager().callEvent(playerInventoryClearEvent);
            }, 2L);
        }
        return;
    }
    if (configValues.isBlockWorldEditNonBuilder()) {
        if (!DISABLED_COMMANDS.contains(command)) {
            return;
        }
        BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
        if (buildWorld == null) {
            return;
        }
        if (disableArchivedWorlds(buildWorld, player, event)) {
            return;
        }
        checkBuilders(buildWorld, player, event);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) PlayerInventoryClearEvent(com.eintosti.buildsystem.event.player.PlayerInventoryClearEvent) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 55 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.

the class PlayerTeleportListener method onPlayerTeleport.

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
    Player player = event.getPlayer();
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.UNKNOWN) {
        playerManager.getPreviousLocation().put(player.getUniqueId(), event.getFrom());
    }
    Location to = event.getTo();
    if (to == null) {
        return;
    }
    World toWorld = to.getWorld();
    if (toWorld == null) {
        return;
    }
    String worldName = to.getWorld().getName();
    BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
    if (buildWorld == null) {
        return;
    }
    if (!Bukkit.getWorlds().get(0).equals(Bukkit.getWorld(worldName))) {
        if (!player.hasPermission(buildWorld.getPermission()) && !buildWorld.getPermission().equalsIgnoreCase("-")) {
            player.sendMessage(plugin.getString("worlds_tp_entry_forbidden"));
            event.setCancelled(true);
        }
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)143 EventHandler (org.bukkit.event.EventHandler)58 Player (org.bukkit.entity.Player)52 World (org.bukkit.World)40 Block (org.bukkit.block.Block)20 ItemStack (org.bukkit.inventory.ItemStack)18 XMaterial (com.cryptomorin.xseries.XMaterial)16 PlayerChatInput (com.eintosti.buildsystem.util.external.PlayerChatInput)16 UUID (java.util.UUID)14 Location (org.bukkit.Location)14 File (java.io.File)12 ArrayList (java.util.ArrayList)9 BuildSystem (com.eintosti.buildsystem.BuildSystem)6 Builder (com.eintosti.buildsystem.object.world.Builder)6 List (java.util.List)6 Bukkit (org.bukkit.Bukkit)6 Material (org.bukkit.Material)6 ChunkGenerator (org.bukkit.generator.ChunkGenerator)6 Inventory (org.bukkit.inventory.Inventory)6 ItemMeta (org.bukkit.inventory.meta.ItemMeta)6