Search in sources :

Example 6 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by Trichtern.

the class WorldsCommand method getPermissionInput.

public void getPermissionInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_setpermission_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_permission", input -> {
        buildWorld.setPermission(input.trim());
        playerManager.forceUpdateSidebar(buildWorld);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_setpermission_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 7 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldsCommand method getAddBuilderInput.

public void getAddBuilderInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_addbuilder_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_player_name", input -> {
        String builderName = input.trim();
        Player builderPlayer = Bukkit.getPlayer(builderName);
        Builder builder;
        UUID builderId;
        if (builderPlayer == null) {
            builderId = UUIDFetcher.getUUID(builderName);
            if (builderId == null) {
                player.sendMessage(plugin.getString("worlds_addbuilder_player_not_found"));
                player.closeInventory();
                return;
            }
            builder = new Builder(builderId, builderName);
        } else {
            builder = new Builder(builderPlayer);
            builderId = builderPlayer.getUniqueId();
        }
        if (buildWorld.getCreatorId() != null && buildWorld.getCreatorId().equals(builderId)) {
            player.sendMessage(plugin.getString("worlds_addbuilder_already_creator"));
            player.closeInventory();
            return;
        }
        if (buildWorld.isBuilder(builderId)) {
            player.sendMessage(plugin.getString("worlds_addbuilder_already_added"));
            player.closeInventory();
            return;
        }
        buildWorld.addBuilder(builder);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_addbuilder_added").replace("%builder%", builderName));
        if (closeInventory) {
            player.closeInventory();
        } else {
            player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
        }
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) Builder(com.eintosti.buildsystem.object.world.Builder) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput) UUID(java.util.UUID)

Example 8 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldsCommand method getRemoveBuilderInput.

public void getRemoveBuilderInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_removebuilder_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_player_name", input -> {
        String builderName = input.trim();
        Player builderPlayer = Bukkit.getPlayer(builderName);
        UUID builderId;
        if (builderPlayer == null) {
            builderId = UUIDFetcher.getUUID(builderName);
            if (builderId == null) {
                player.sendMessage(plugin.getString("worlds_removebuilder_player_not_found"));
                player.closeInventory();
                return;
            }
        } else {
            builderId = builderPlayer.getUniqueId();
        }
        if (buildWorld.getCreatorId() != null && buildWorld.getCreatorId().equals(builderId)) {
            player.sendMessage(plugin.getString("worlds_removebuilder_not_yourself"));
            player.closeInventory();
            return;
        }
        if (!buildWorld.isBuilder(builderId)) {
            player.sendMessage(plugin.getString("worlds_removebuilder_not_builder"));
            player.closeInventory();
            return;
        }
        buildWorld.removeBuilder(builderId);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_removebuilder_removed").replace("%builder%", builderName));
        if (closeInventory) {
            player.closeInventory();
        } else {
            player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
        }
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput) UUID(java.util.UUID)

Example 9 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldsCommand method getPermissionInput.

public void getPermissionInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_setpermission_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_permission", input -> {
        buildWorld.setPermission(input.trim());
        playerManager.forceUpdateSidebar(buildWorld);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_setpermission_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 10 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by Trichtern.

the class WorldsCommand method getAddBuilderInput.

public void getAddBuilderInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_addbuilder_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_player_name", input -> {
        String builderName = input.trim();
        Player builderPlayer = Bukkit.getPlayerExact(builderName);
        Builder builder;
        UUID builderId;
        if (builderPlayer == null) {
            builderId = UUIDFetcher.getUUID(builderName);
            if (builderId == null) {
                player.sendMessage(plugin.getString("worlds_addbuilder_player_not_found"));
                player.closeInventory();
                return;
            }
            builder = new Builder(builderId, builderName);
        } else {
            builder = new Builder(builderPlayer);
            builderId = builderPlayer.getUniqueId();
        }
        if (builderId.equals(player.getUniqueId()) && buildWorld.isCreator(player)) {
            player.sendMessage(plugin.getString("worlds_addbuilder_already_creator"));
            player.closeInventory();
            return;
        }
        if (buildWorld.isBuilder(builderId)) {
            player.sendMessage(plugin.getString("worlds_addbuilder_already_added"));
            player.closeInventory();
            return;
        }
        buildWorld.addBuilder(builder);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_addbuilder_added").replace("%builder%", builderName));
        if (closeInventory) {
            player.closeInventory();
        } else {
            player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
        }
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) Builder(com.eintosti.buildsystem.object.world.Builder) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput) UUID(java.util.UUID)

Aggregations

BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)14 PlayerChatInput (com.eintosti.buildsystem.util.external.PlayerChatInput)14 UUID (java.util.UUID)4 Player (org.bukkit.entity.Player)4 Builder (com.eintosti.buildsystem.object.world.Builder)2 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)2 ChunkGenerator (org.bukkit.generator.ChunkGenerator)2