Search in sources :

Example 46 with BuildWorld

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

the class FilteredWorldsInventory method addWorlds.

private void addWorlds(Player player) {
    int numWorlds = numOfWorlds(player);
    int numInventories = (numWorlds % MAX_WORLDS == 0 ? numWorlds : numWorlds + 1) != 0 ? (numWorlds % MAX_WORLDS == 0 ? numWorlds : numWorlds + 1) : 1;
    inventories = new Inventory[numInventories];
    Inventory inventory = createInventory(player);
    int index = 0;
    inventories[index] = inventory;
    if (numWorlds == 0) {
        inventoryManager.addUrlSkull(inventory, 22, plugin.getString(noWorldsText), "https://textures.minecraft.net/texture/2e3f50ba62cbda3ecf5479b62fedebd61d76589771cc19286bf2745cd71e47c6");
        return;
    }
    int columnWorld = 9, maxColumnWorld = 44;
    for (BuildWorld buildWorld : inventoryManager.sortWorlds(worldManager, plugin.getSettingsManager().getSettings(player))) {
        if (isValidWorld(player, buildWorld)) {
            inventoryManager.addWorldItem(player, inventory, columnWorld++, buildWorld);
        }
        if (columnWorld > maxColumnWorld) {
            columnWorld = 9;
            inventory = createInventory(player);
            inventories[++index] = inventory;
        }
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Inventory(org.bukkit.inventory.Inventory)

Example 47 with BuildWorld

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

the class GameRuleInventory method onInventoryClick.

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    if (!inventoryManager.checkIfValidClick(event, "worldeditor_gamerules_title")) {
        return;
    }
    ItemStack itemStack = event.getCurrentItem();
    if (itemStack == null) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    BuildWorld buildWorld = plugin.getPlayerManager().getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_edit_error"));
        return;
    }
    GameRules gameRules = plugin.getGameRules();
    switch(itemStack.getType()) {
        case PLAYER_HEAD:
            int slot = event.getSlot();
            if (slot == 36) {
                gameRules.decrementInv(player);
            } else if (slot == 44) {
                gameRules.incrementInv(player);
            }
            break;
        case FILLED_MAP:
        case MAP:
            World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
            gameRules.toggleGameRule(event, bukkitWorld);
            break;
        default:
            XSound.BLOCK_CHEST_OPEN.play(player);
            plugin.getEditInventory().openInventory(player, buildWorld);
            return;
    }
    XSound.ENTITY_CHICKEN_EGG.play(player);
    openInventory(player, buildWorld);
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) GameRules(com.eintosti.buildsystem.version.GameRules) ItemStack(org.bukkit.inventory.ItemStack) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) EventHandler(org.bukkit.event.EventHandler)

Example 48 with BuildWorld

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

the class GameRuleInventory method openInventory.

public void openInventory(Player player, BuildWorld buildWorld) {
    World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
    Inventory inventory = plugin.getGameRules().getInventory(player, bukkitWorld);
    fillGuiWithGlass(player, inventory);
    player.openInventory(inventory);
}
Also used : World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Inventory(org.bukkit.inventory.Inventory)

Example 49 with BuildWorld

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

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

Example 50 with BuildWorld

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

the class WorldManipulateListener method onPlayerArmorStandManipulate.

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) {
    Player player = event.getPlayer();
    BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
    if (buildWorld == null) {
        return;
    }
    manageWorldInteraction(player, event, buildWorld.isBlockInteractions());
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) 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