Search in sources :

Example 1 with ResidentConversation

use of com.palmergames.bukkit.towny.conversation.ResidentConversation in project Towny by TownyAdvanced.

the class PermissionGUIUtil method handleConversation.

public static void handleConversation(Player player) {
    TownBlock startingTownBlock = WorldCoord.parseWorldCoord(player).getTownBlockOrNull();
    if (startingTownBlock == null) {
        TownyMessaging.sendErrorMsg(player, Translatable.of("msg_not_claimed_1"));
        return;
    }
    new ResidentConversation(player).runOnResponse((res) -> {
        if (!TownyUniverse.getInstance().getPermissionSource().testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_PERM_ADD.getNode())) {
            TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_command_disable"));
            return;
        }
        Resident resident = (Resident) res;
        if (startingTownBlock.hasPlotObjectGroup()) {
            PlotGroup group = startingTownBlock.getPlotObjectGroup();
            if (group.getPermissionOverrides().containsKey(resident)) {
                TownyMessaging.sendErrorMsg(player, Translatable.of("msg_overrides_already_set", resident.getName(), Translatable.of("plotgroup_sing")));
                return;
            }
            group.putPermissionOverride(resident, new PermissionData(PermissionGUIUtil.getDefaultTypes(), player.getName()));
        } else {
            if (startingTownBlock.getPermissionOverrides().containsKey(resident)) {
                TownyMessaging.sendErrorMsg(player, Translatable.of("msg_overrides_already_set", resident.getName(), Translatable.of("townblock")));
                return;
            }
            startingTownBlock.getPermissionOverrides().put(resident, new PermissionData(PermissionGUIUtil.getDefaultTypes(), player.getName()));
            startingTownBlock.save();
        }
        TownyMessaging.sendMsg(player, Translatable.of("msg_overrides_added", resident.getName()));
        PermissionGUIUtil.openPermissionGUI(TownyAPI.getInstance().getResident(player), startingTownBlock);
    });
}
Also used : ResidentConversation(com.palmergames.bukkit.towny.conversation.ResidentConversation) Resident(com.palmergames.bukkit.towny.object.Resident) PlotGroup(com.palmergames.bukkit.towny.object.PlotGroup) TownBlock(com.palmergames.bukkit.towny.object.TownBlock) PermissionData(com.palmergames.bukkit.towny.object.PermissionData)

Aggregations

ResidentConversation (com.palmergames.bukkit.towny.conversation.ResidentConversation)1 PermissionData (com.palmergames.bukkit.towny.object.PermissionData)1 PlotGroup (com.palmergames.bukkit.towny.object.PlotGroup)1 Resident (com.palmergames.bukkit.towny.object.Resident)1 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)1