Search in sources :

Example 16 with BuildWorld

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

the class FoodLevelChangeListener method onFoodLevelChangeEvent.

@EventHandler
public void onFoodLevelChangeEvent(FoodLevelChangeEvent event) {
    if (!(event.getEntity() instanceof Player)) {
        return;
    }
    Player player = (Player) event.getEntity();
    World bukkitWorld = player.getWorld();
    BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
    if (buildWorld != null && buildWorld.getStatus() == WorldStatus.ARCHIVE) {
        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) EventHandler(org.bukkit.event.EventHandler)

Example 17 with BuildWorld

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

the class EditInventory method addTimeItem.

private void addTimeItem(Inventory inventory, BuildWorld buildWorld) {
    World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
    XMaterial xMaterial = XMaterial.WHITE_STAINED_GLASS;
    String value = plugin.getString("worldeditor_time_lore_unknown");
    BuildWorld.Time time = getWorldTime(bukkitWorld);
    switch(time) {
        case SUNRISE:
            xMaterial = XMaterial.ORANGE_STAINED_GLASS;
            value = plugin.getString("worldeditor_time_lore_sunrise");
            break;
        case NOON:
            xMaterial = XMaterial.YELLOW_STAINED_GLASS;
            value = plugin.getString("worldeditor_time_lore_noon");
            break;
        case NIGHT:
            xMaterial = XMaterial.BLUE_STAINED_GLASS;
            value = plugin.getString("worldeditor_time_lore_night");
            break;
    }
    ArrayList<String> lore = new ArrayList<>();
    String finalValue = value;
    plugin.getStringList("worldeditor_time_lore").forEach(line -> lore.add(line.replace("%time%", finalValue)));
    inventoryManager.addItemStack(inventory, 23, xMaterial, plugin.getString("worldeditor_time_item"), lore);
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) ArrayList(java.util.ArrayList) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) XMaterial(com.cryptomorin.xseries.XMaterial)

Example 18 with BuildWorld

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

the class EditInventory method changeTime.

private void changeTime(Player player, BuildWorld buildWorld) {
    World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
    if (bukkitWorld == null) {
        return;
    }
    BuildWorld.Time time = getWorldTime(bukkitWorld);
    switch(time) {
        case SUNRISE:
            bukkitWorld.setTime(configValues.getNoonTime());
            break;
        case NOON:
            bukkitWorld.setTime(configValues.getNightTime());
            break;
        case NIGHT:
            bukkitWorld.setTime(configValues.getSunriseTime());
            break;
    }
    openInventory(player, buildWorld);
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

Example 19 with BuildWorld

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

the class EditInventory method removeEntities.

private void removeEntities(Player player, BuildWorld buildWorld) {
    World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
    if (bukkitWorld == null) {
        return;
    }
    AtomicInteger entitiesRemoved = new AtomicInteger();
    bukkitWorld.getEntities().stream().filter(entity -> !IGNORED_ENTITIES.contains(entity.getType())).forEach(entity -> {
        entity.remove();
        entitiesRemoved.incrementAndGet();
    });
    player.closeInventory();
    player.sendMessage(plugin.getString("worldeditor_butcher_removed").replace("%amount%", String.valueOf(entitiesRemoved.get())));
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) BuildSystem(com.eintosti.buildsystem.BuildSystem) Enchantment(org.bukkit.enchantments.Enchantment) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Player(org.bukkit.entity.Player) Inventory(org.bukkit.inventory.Inventory) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) World(org.bukkit.World) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) XSound(com.cryptomorin.xseries.XSound) ConfigValues(com.eintosti.buildsystem.util.ConfigValues) InventoryManager(com.eintosti.buildsystem.manager.InventoryManager) PlayerManager(com.eintosti.buildsystem.manager.PlayerManager) InventoryClickEvent(org.bukkit.event.inventory.InventoryClickEvent) Set(java.util.Set) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) Sets(com.google.common.collect.Sets) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) ChatColor(org.bukkit.ChatColor) XMaterial(com.cryptomorin.xseries.XMaterial) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

Example 20 with BuildWorld

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

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)

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