Search in sources :

Example 36 with BuildWorld

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

the class SpawnCommand method onCommand.

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
    if (!(sender instanceof Player)) {
        plugin.getLogger().warning(plugin.getString("sender_not_player"));
        return true;
    }
    Player player = (Player) sender;
    switch(args.length) {
        case 0:
            if (!spawnManager.teleport(player)) {
                player.sendMessage(plugin.getString("spawn_unavailable"));
            } else if (plugin.getConfigValues().isSpawnTeleportMessage()) {
                player.sendMessage(plugin.getString("spawn_teleported"));
            }
            break;
        case 1:
            if (!player.hasPermission("buildsystem.spawn")) {
                player.sendMessage(plugin.getString("spawn_usage"));
                return true;
            }
            switch(args[0].toLowerCase()) {
                case "set":
                    Location playerLocation = player.getLocation();
                    World bukkitWorld = playerLocation.getWorld();
                    BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
                    if (buildWorld == null) {
                        player.sendMessage(plugin.getString("spawn_world_not_imported"));
                        return true;
                    }
                    spawnManager.set(playerLocation, buildWorld.getName());
                    player.sendMessage(plugin.getString("spawn_set").replace("%x%", round(playerLocation.getX())).replace("%y%", round(playerLocation.getY())).replace("%z%", round(playerLocation.getZ())).replace("%world%", playerLocation.getWorld().getName()));
                    break;
                case "remove":
                    spawnManager.remove();
                    player.sendMessage(plugin.getString("spawn_remove"));
                    break;
                default:
                    player.sendMessage(plugin.getString("spawn_admin"));
                    break;
            }
            break;
        default:
            if (player.hasPermission("buildsystem.spawn")) {
                player.sendMessage(plugin.getString("spawn_admin"));
            } else {
                player.sendMessage(plugin.getString("spawn_usage"));
            }
            break;
    }
    return 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)

Example 37 with BuildWorld

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

the class WorldsCommand method getProjectInput.

public void getProjectInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_setproject_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_project", input -> {
        buildWorld.setProject(input.trim());
        playerManager.forceUpdateSidebar(buildWorld);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_setproject_set").replace("%world%", buildWorld.getName()));
        if (closeInventory) {
            player.closeInventory();
        } else {
            player.openInventory(plugin.getEditInventory().getInventory(player, buildWorld));
        }
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput)

Example 38 with BuildWorld

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

the class WorldsCommand method getCreatorInput.

private void getCreatorInput(Player player) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_setcreator_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_creator", input -> {
        String creator = input.trim();
        buildWorld.setCreator(creator);
        if (!creator.equalsIgnoreCase("-")) {
            buildWorld.setCreatorId(UUIDFetcher.getUUID(creator));
        } else {
            buildWorld.setCreatorId(null);
        }
        playerManager.forceUpdateSidebar(buildWorld);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_setcreator_set").replace("%world%", buildWorld.getName()));
        player.closeInventory();
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput)

Example 39 with BuildWorld

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

the class WorldsCommand method getRenameInput.

private void getRenameInput(Player player) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_rename_unknown_world"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_name", input -> {
        player.closeInventory();
        worldManager.renameWorld(player, buildWorld, input.trim());
        playerManager.getSelectedWorld().remove(player.getUniqueId());
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.closeInventory();
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput)

Example 40 with BuildWorld

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

the class SettingsManager method injectPlaceholders.

private String injectPlaceholders(String originalString, Player player) {
    if (!originalString.matches(".*%*%.*")) {
        return originalString;
    }
    String worldName = player.getWorld().getName();
    BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
    return originalString.replace("%world%", worldName).replace("%status%", parseWorldInformation(buildWorld, "%status%")).replace("%permission%", parseWorldInformation(buildWorld, "%permission%")).replace("%project%", parseWorldInformation(buildWorld, "%project%")).replace("%creator%", parseWorldInformation(buildWorld, "%creator%")).replace("%creation%", parseWorldInformation(buildWorld, "%creation%"));
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

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