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);
});
}
Aggregations